@@ -0,0 +1,2475 @@
+package uk.ac.ebi.quickgo.rest.cache;%0A%0Aimport java.time.Duration;%0Aimport java.time.LocalTime;%0Aimport java.util.function.Supplier;%0Aimport org.junit.Test;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.Matchers.both;%0Aimport static org.hamcrest.Matchers.greaterThan;%0Aimport static org.hamcrest.Matchers.lessThan;%0Aimport static org.hamcrest.core.Is.is;%0A%0A/**%0A * Test methods in the CacheStrategy class.%0A *%0A * @author Tony Wardell%0A * Date: 05/04/2017%0A * Time: 13:26%0A * Created with IntelliJ IDEA.%0A */%0Apublic class MaxAgeWhenStartBeforeEndTimeTest %7B%0A%0A    @Test%0A    public void secondsLeftWhenNowBetweenStartTimeAndEndTime()%7B%0A%0A        LocalTime now = LocalTime.now();%0A        LocalTime startTime = now.minusMinutes(1);%0A        LocalTime endTime = now.plusMinutes(1);%0A%0A        if(startTime.isAfter(endTime))%7B%0A            //Evidently this test is running at midnight - the time has wrapped and we need to bail out%0A            return;%0A        %7D%0A        Long totalTimeLeft = Duration.between(now, endTime).getSeconds();%0A%0A        Supplier%3CDuration%3E maxAge = new MaxAgeWhenStartBeforeEndTime(startTime, endTime);%0A        long timeLeft = maxAge.get().getSeconds();%0A%0A        //Provide a little wriggle room for test%0A        Long rangeLowPoint = totalTimeLeft - 3;%0A        Long rangeHighPoint = totalTimeLeft + 3;%0A        assertThat(timeLeft, is(both(greaterThan(rangeLowPoint)).and(lessThan(rangeHighPoint))));%0A    %7D%0A%0A    @Test%0A    public void durationZeroWhenNowfterEndTime()%7B%0A%0A        LocalTime now = LocalTime.now();%0A        LocalTime startTime = now.minusMinutes(2);%0A        LocalTime endTime = now.minusMinutes(1);%0A        if(startTime.isAfter(endTime))%7B%0A            //we've running this test at midnight, the time has wrapped and we need to bail out%0A            return;%0A        %7D%0A        Supplier%3CDuration%3E maxAge = new MaxAgeWhenStartBeforeEndTime(startTime, endTime);%0A        assertThat(maxAge.get(), is(Duration.ZERO));%0A    %7D%0A%0A    @Test%0A    public void durationZeroWhenNowBeforeStartTime()%7B%0A%0A        LocalTime now = LocalTime.now();%0A        LocalTime startTime = now.plusMinutes(1);%0A        LocalTime endTime = now.plusMinutes(2);%0A        if(startTime.isAfter(endTime))%7B%0A            //we've running this test at midnight, the time has wrapped and we need to bail out%0A            return;%0A        %7D%0A        Supplier%3CDuration%3E maxAge = new MaxAgeWhenStartBeforeEndTime(startTime, endTime);%0A        assertThat(maxAge.get(), is(Duration.ZERO));%0A    %7D%0A%7D%0A

Test MaxAgeWhenStartBeforeEndTimeTest