Search in sources :

Example 6 with ConsecutiveDaysTimeframe

use of de.avanux.smartapplianceenabler.schedule.ConsecutiveDaysTimeframe in project SmartApplianceEnabler by camueller.

the class ConsecutiveDaysTimeframeTest method getIntervals_AcrossWeeks_AfterIntervalEnd.

@Test
public void getIntervals_AcrossWeeks_AfterIntervalEnd() {
    TimeOfDayOfWeek startTimeOfDayOfWeek = new TimeOfDayOfWeek(6, 15, 0, 0);
    TimeOfDayOfWeek endTimeOfDayOfWeek = new TimeOfDayOfWeek(1, 20, 0, 0);
    ConsecutiveDaysTimeframe timeRange = new ConsecutiveDaysTimeframe(startTimeOfDayOfWeek, endTimeOfDayOfWeek);
    LocalDateTime now = toDayOfWeek(1, 21, 0, 0);
    List<TimeframeInterval> intervals = timeRange.getIntervals(now);
    Assert.assertEquals(1, intervals.size());
    LocalDateTime start = startTimeOfDayOfWeek.toNextOccurrence(now);
    assertDateTime(start, intervals.get(0).getInterval().getStart().toLocalDateTime());
    assertDateTime(endTimeOfDayOfWeek.toNextOccurrence(start), intervals.get(0).getInterval().getEnd().toLocalDateTime());
}
Also used : TimeOfDayOfWeek(de.avanux.smartapplianceenabler.schedule.TimeOfDayOfWeek) LocalDateTime(org.joda.time.LocalDateTime) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) ConsecutiveDaysTimeframe(de.avanux.smartapplianceenabler.schedule.ConsecutiveDaysTimeframe) Test(org.junit.Test)

Aggregations

ConsecutiveDaysTimeframe (de.avanux.smartapplianceenabler.schedule.ConsecutiveDaysTimeframe)6 TimeOfDayOfWeek (de.avanux.smartapplianceenabler.schedule.TimeOfDayOfWeek)6 TimeframeInterval (de.avanux.smartapplianceenabler.schedule.TimeframeInterval)6 LocalDateTime (org.joda.time.LocalDateTime)6 Test (org.junit.Test)6