<commit_before>package org.hisp.dhis.android.rules;

import org.hisp.dhis.android.rules.models.RuleAttributeValue;
import org.hisp.dhis.android.rules.models.RuleDataValue;
import org.hisp.dhis.android.rules.models.RuleEnrollment;
import org.hisp.dhis.android.rules.models.RuleEvent;
import org.hisp.dhis.android.rules.models.RuleValueType;
import org.hisp.dhis.android.rules.models.RuleVariable;
import org.hisp.dhis.android.rules.models.RuleVariableAttribute;
import org.hisp.dhis.android.rules.models.RuleVariableCurrentEvent;
import org.hisp.dhis.android.rules.models.RuleVariableNewestEvent;
import org.hisp.dhis.android.rules.models.RuleVariableNewestStageEvent;
import org.hisp.dhis.android.rules.models.RuleVariablePreviousEvent;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
import java.util.Map;

import static junit.framework.TestCase.fail;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.hisp.dhis.android.rules.RuleVariableValueAssert.assertThatVariable;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

// ToDo: add tests to check that the same event is not added twice to the list
// ToDo: tests for concurrent modification exceptions
@RunWith(JUnit4.class)
public class RuleVariableValueMapBuilderTests {
    private static final String DATE_PATTERN = "yyyy-MM-dd";
    private SimpleDateFormat dateFormat;

    @Before
    public void setUp() throws Exception {
        dateFormat = new SimpleDateFormat(DATE_PATTERN, Locale.US);
    }

    @Test
    public void buildShouldReturnImmutableMap() throws ParseException {
        RuleEvent ruleEvent = mock(RuleEvent.class);
        when(ruleEvent.eventDate()).thenReturn(dateFormat.parse("1994-02-03"));
        when(ruleEvent.dueDate()).thenReturn(dateFormat.parse("1995-02-03"));

        try {
            RuleVariableValueMapBuilder.target(ruleEvent)
                    .ruleVariables(new ArrayList<RuleVariable>())
                    .build().clear();
            fail("UnsupportedOperationException expected, but nothing was thrown");
        } catch (UnsupportedOperationException exception) {
            // noop<commit_msg>Removed todos.<commit_after>package org.hisp.dhis.android.rules;

import org.hisp.dhis.android.rules.models.RuleAttributeValue;
import org.hisp.dhis.android.rules.models.RuleDataValue;
import org.hisp.dhis.android.rules.models.RuleEnrollment;
import org.hisp.dhis.android.rules.models.RuleEvent;
import org.hisp.dhis.android.rules.models.RuleValueType;
import org.hisp.dhis.android.rules.models.RuleVariable;
import org.hisp.dhis.android.rules.models.RuleVariableAttribute;
import org.hisp.dhis.android.rules.models.RuleVariableCurrentEvent;
import org.hisp.dhis.android.rules.models.RuleVariableNewestEvent;
import org.hisp.dhis.android.rules.models.RuleVariableNewestStageEvent;
import org.hisp.dhis.android.rules.models.RuleVariablePreviousEvent;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
import java.util.Map;

import static junit.framework.TestCase.fail;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.hisp.dhis.android.rules.RuleVariableValueAssert.assertThatVariable;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(JUnit4.class)
public class RuleVariableValueMapBuilderTests {
    private static final String DATE_PATTERN = "yyyy-MM-dd";
    private SimpleDateFormat dateFormat;

    @Before
    public void setUp() throws Exception {
        dateFormat = new SimpleDateFormat(DATE_PATTERN, Locale.US);
    }

    @Test
    public void buildShouldReturnImmutableMap() throws ParseException {
        RuleEvent ruleEvent = mock(RuleEvent.class);
        when(ruleEvent.eventDate()).thenReturn(dateFormat.parse("1994-02-03"));
        when(ruleEvent.dueDate()).thenReturn(dateFormat.parse("1995-02-03"));

        try {
            RuleVariableValueMapBuilder.target(ruleEvent)
                    .ruleVariables(new ArrayList<RuleVariable>())
                    .build().clear();
            fail("UnsupportedOperationException expected, but nothing was thrown");
        } catch (UnsupportedOperationException exception) {
            // noop
{'fraction_non_alphanumeric': 0.10385438972162742, 'fraction_numerical': 0.008137044967880086, 'mean_word_length': 4.437718277066356, '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': '2375470', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1372, 'n_words': 242}