package uk.ac.ebi.quickgo.rest.period;

import java.time.DayOfWeek;
import java.time.LocalDateTime;
import java.time.LocalTime;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;

/**
 * Test instantiation of the DayTime class.
 *
 * @author Tony Wardell
 * Date: 18/04/2017
 * Time: 10:43
 * Created with IntelliJ IDEA.
 */
public class DayTimeTest {

    @Test
    public void instantiateDayTimeWithValidValues(){
       DayTime validDayTime = new DayTime(DayOfWeek.FRIDAY, LocalTime.of(12, 37));

       assertThat(validDayTime, notNullValue());
    }

    @Test(expected = IllegalArgumentException.class)
    public void nullDayOfWeekCreatesException(){
        new DayTime(null, LocalTime.of(12, 37));
    }

    @Test(expected = IllegalArgumentException.class)
    public void nullLocalTimeCreatesException(){
        new DayTime(DayOfWeek.FRIDAY, null);
    }

    @Test
    public void modify(){
        DayTime dayTime = new DayTime(DayOfWeek.FRIDAY, LocalTime.of(12, 37));
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime compared = now.with(DayOfWeek.FRIDAY);
        LocalTime localTime = LocalTime.of(12, 37);
        compared = compared.with(localTime);

        LocalDateTime modified = dayTime.modify(now);

        assertThat(modified, equalTo(compared));
    }
}

@@ -1017,16 +1017,28 @@
 d modify
+Successfully
 ()%7B%0A    
@@ -1429,11 +1429,226 @@
 );%0A    %7D
+%0A%0A    @Test(expected = IllegalArgumentException.class)%0A    public void modifyNullThrowsException()%7B%0A        DayTime dayTime = new DayTime(DayOfWeek.FRIDAY, LocalTime.of(12, 37));%0A%0A        dayTime.modify(null);%0A    %7D
 %0A%7D%0A

Add test for null being passed to modify();