<commit_before>package org.openlmis.core.model;

import org.junit.Before;
import org.junit.Test;
import org.openlmis.core.utils.DateUtil;

import java.util.Date;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class RnRFormTest {
    @Before
    public void setUp() {
    }

    @Test
    public void shouldGetPeriodByPeriodBegin() throws Exception {
        RnRForm rnRForm=new RnRForm();
        Date periodBegin = DateUtil.parseString("21/09/2015", DateUtil.SIMPLE_DATE_FORMAT);
        rnRForm.setPeriodBegin(periodBegin);
        RnRForm.setPeriodByPeriodBegin(rnRForm);

        assertThat(rnRForm.getPeriodBegin(), is(periodBegin));
        Date periodEnd = DateUtil.parseString("20/10/2015", DateUtil.SIMPLE_DATE_FORMAT);
        assertThat(rnRForm.getPeriodEnd(),is(periodEnd));
    }

    @Test
    public void shouldGetPeriodByPeriodBeginAtCriticalPoint() throws Exception {
        RnRForm rnRForm=new RnRForm();
        Date periodBegin = DateUtil.parseString("21/12/2015", DateUtil.SIMPLE_DATE_FORMAT);
        rnRForm.setPeriodBegin(periodBegin);
        RnRForm.setPeriodByPeriodBegin(rnRForm);

        assertThat(rnRForm.getPeriodBegin(), is(periodBegin));
        Date periodEnd = DateUtil.parseString("20/01/2016", DateUtil.SIMPLE_DATE_FORMAT);
        assertThat(rnRForm.getPeriodEnd(),is(periodEnd));
    }


}
<commit_msg>CPF - #000 - extract method to simplify form period test<commit_after>package org.openlmis.core.model;

import org.junit.Test;

import java.util.Date;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.openlmis.core.utils.DateUtil.SIMPLE_DATE_FORMAT;
import static org.openlmis.core.utils.DateUtil.parseString;

public class RnRFormTest {

    @Test
    public void shouldGetPeriodByPeriodBegin() throws Exception {
        Date periodBegin = parseString("21/09/2015", SIMPLE_DATE_FORMAT);
        Date periodEnd = parseString("20/10/2015", SIMPLE_DATE_FORMAT);

        testPeriodBeginEnd(periodBegin, periodEnd);
    }

    @Test
    public void shouldGetPeriodByPeriodBeginAtCriticalPoint() throws Exception {
        Date periodBegin = parseString("21/12/2015", SIMPLE_DATE_FORMAT);
        Date periodEnd = parseString("20/01/2016", SIMPLE_DATE_FORMAT);

        testPeriodBeginEnd(periodBegin, periodEnd);
    }

    private void testPeriodBeginEnd(Date givenBegin, Date expectedEnd) {
        RnRForm rnRForm = new RnRForm();
        rnRForm.setPeriodBegin(givenBegin);
        RnRForm.setPeriodByPeriodBegin(rnRForm);

        assertThat(rnRForm.getPeriodBegin(), is(givenBegin));
        assertThat(rnRForm.getPeriodEnd(), is(expectedEnd));
    }

}

{'fraction_non_alphanumeric': 0.10187568959176167, 'fraction_numerical': 0.024641412283927914, 'mean_word_length': 4.027726432532347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4820997', 'n_tokens_mistral': 907, 'n_tokens_neox': 840, 'n_words': 144}