<commit_before>package uk.ac.ebi.quickgo.rest.period;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.util.Optional;
import org.junit.Test;

import static java.util.Optional.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

/**
 * Tests the creation of DayTime instances from DailyPeriodParser.
 *
 * @author <NAME>
 * Date: 12/04/2017
 * Time: 15:27
 * Created with IntelliJ IDEA.
 */
public class DailyPeriodParserTest {

    private final DailyPeriodParser dailyPeriodParser = new DailyPeriodParser();

    @Test
    public void validInputString(){
        String validInput="MONDAY(21:30)-TUESDAY(21:30)";
        DateModifier start = new DayTime(DayOfWeek.MONDAY, LocalTime.of(21, 30));
        DateModifier end = new DayTime(DayOfWeek.TUESDAY, LocalTime.of(21, 30));
        RemainingTimePeriod remainingTimePeriod = new RemainingTimePeriod(start, end);

        Optional<Period> result = dailyPeriodParser.parse(validInput);

        assertThat(result.get(), equalTo(remainingTimePeriod));
    }

    @Test
    public void nullInput(){
        Optional<Period> result = dailyPeriodParser.parse(null);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void emptyInput(){
        Optional<Period> result = dailyPeriodParser.parse("");

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void missingDataCreatesEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void tooMuchDataCreatesEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-TUESDAY(21:30)-WEDNESDAY(21:30)";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void invalidDayOfWeekCreateEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-FEBRUARY(21:30)";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void invalidTimeCreatesEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-TUESDAY(33:30)";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }
}<commit_msg>Improve test method names.<commit_after>package uk.ac.ebi.quickgo.rest.period;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.util.Optional;
import org.junit.Test;

import static java.util.Optional.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

/**
 * Tests the creation of DayTime instances from DailyPeriodParser.
 *
 * @author <NAME>
 * Date: 12/04/2017
 * Time: 15:27
 * Created with IntelliJ IDEA.
 */
public class DailyPeriodParserTest {

    private final DailyPeriodParser dailyPeriodParser = new DailyPeriodParser();

    @Test
    public void validInputCreatesPeriodSuccessfully(){
        String validInput="MONDAY(21:30)-TUESDAY(21:30)";
        DateModifier start = new DayTime(DayOfWeek.MONDAY, LocalTime.of(21, 30));
        DateModifier end = new DayTime(DayOfWeek.TUESDAY, LocalTime.of(21, 30));
        RemainingTimePeriod remainingTimePeriod = new RemainingTimePeriod(start, end);

        Optional<Period> result = dailyPeriodParser.parse(validInput);

        assertThat(result.get(), equalTo(remainingTimePeriod));
    }

    @Test
    public void nullInputCreatesEmptyPeriod(){
        Optional<Period> result = dailyPeriodParser.parse(null);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void emptyInputCreatesEmptyPeriod(){
        Optional<Period> result = dailyPeriodParser.parse("");

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void missingEndValueCreatesEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void tooMuchDataCreatesEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-TUESDAY(21:30)-WEDNESDAY(21:30)";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void invalidDayOfWeekCreateEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-FEBRUARY(21:30)";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }

    @Test
    public void invalidEndTimeCreatesEmptyPeriod(){
        String invalidInput="MONDAY(21:30)-TUESDAY(33:30)";

        Optional<Period> result = dailyPeriodParser.parse(invalidInput);

        assertThat(result, equalTo(empty()));
    }
}
{'fraction_non_alphanumeric': 0.11700596339708, 'fraction_numerical': 0.024676125848241828, 'mean_word_length': 3.811078140454995, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4743999', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1393, 'n_words': 275}