<commit_before>package org.forest.mapping;

import junit.framework.Assert;
import org.forest.config.ForestConfiguration;
import org.forest.reflection.ForestMethod;
import org.junit.Test;
import org.mockito.Mockito;

/**
 * @author gongjun[<EMAIL>]
 * @since 2017-05-08 17:41
 */
public class TestMappingReference {

    @Test
    public void testParameter() {
        ForestMethod forestMethod = Mockito.mock(ForestMethod.class);
        MappingVariable nameVar = new MappingVariable("name", String.class);
        nameVar.setIndex(0);
        MappingVariable ageVar = new MappingVariable("age", String.class);
        ageVar.setIndex(1);
        Mockito.when(forestMethod.getVariable("name")).thenReturn(nameVar);
        Mockito.when(forestMethod.getVariable("age")).thenReturn(ageVar);
        Mockito.when(forestMethod.getVariableValue("name")).thenReturn("Marry");
        Mockito.when(forestMethod.getVariableValue("matherName")).thenReturn("Linda");
        Mockito.when(forestMethod.getVariableValue("age")).thenReturn(12);
        MappingReference nameRef = new MappingReference(forestMethod, "name");
        MappingReference ageRef = new MappingReference(forestMethod, "age");
        MappingReference matherNameRef = new MappingReference(forestMethod, "matherName");
        Assert.assertEquals("Peter", nameRef.render(new Object[] {"Peter", 15}));
        Mockito.verify(forestMethod).getVariable("name");
        Mockito.verify(forestMethod, Mockito.never()).getVariableValue("name");
        Assert.assertEquals(15, ageRef.render(new Object[] {"Peter", 15}));
        Assert.assertEquals("Linda", matherNameRef.render(new Object[] {"Peter", 15}));
    }
}<commit_msg>测试MappingReference<commit_after>package org.forest.mapping;

import junit.framework.Assert;
import org.forest.config.ForestConfiguration;
import org.forest.reflection.ForestMethod;
import org.junit.Test;
import org.mockito.Mockito;

/**
 * @author gongjun[<EMAIL>]
 * @since 2017-05-08 17:41
 */
public class TestMappingReference {

    @Test
    public void testParameter() {
        ForestMethod forestMethod = Mockito.mock(ForestMethod.class);
        MappingVariable nameVar = new MappingVariable("name", String.class);
        nameVar.setIndex(0);
        MappingVariable ageVar = new MappingVariable("age", String.class);
        ageVar.setIndex(1);
        Mockito.when(forestMethod.getVariable("name")).thenReturn(nameVar);
        Mockito.when(forestMethod.getVariable("age")).thenReturn(ageVar);
        Mockito.when(forestMethod.getVariableValue("name")).thenReturn("Marry");
        Mockito.when(forestMethod.getVariableValue("motherName")).thenReturn("Linda");
        Mockito.when(forestMethod.getVariableValue("age")).thenReturn(12);
        MappingReference nameRef = new MappingReference(forestMethod, "name");
        MappingReference ageRef = new MappingReference(forestMethod, "age");
        MappingReference motherNameRef = new MappingReference(forestMethod, "motherName");
        Assert.assertEquals("Peter", nameRef.render(new Object[] {"Peter", 15}));
        Mockito.verify(forestMethod).getVariable("name");
        Mockito.verify(forestMethod, Mockito.never()).getVariableValue("name");
        Assert.assertEquals(15, ageRef.render(new Object[] {"Peter", 15}));
        Mockito.verify(forestMethod, Mockito.never()).getVariableValue("motherName");
        Assert.assertEquals("Linda", motherNameRef.render(new Object[] {"Peter", 15}));
        Mockito.verify(forestMethod).getVariableValue("motherName");

    }
}
{'fraction_non_alphanumeric': 0.13787234042553193, 'fraction_numerical': 0.013617021276595745, 'mean_word_length': 4.5968253968253965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6988645', 'n_tokens_mistral': 1068, 'n_tokens_neox': 985, 'n_words': 157}