Search in sources :

Example 1 with ConsecutiveDaysTimeframe

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

the class ConsecutiveDaysTimeframeTest method getIntervals_AcrossWeeks_WithinInterval.

@Test
public void getIntervals_AcrossWeeks_WithinInterval() {
    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(7, 10, 0, 0);
    List<TimeframeInterval> intervals = timeRange.getIntervals(now);
    Assert.assertEquals(1, intervals.size());
    LocalDateTime start = startTimeOfDayOfWeek.toLastOccurrence(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)

Example 2 with ConsecutiveDaysTimeframe

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

the class ConsecutiveDaysTimeframeTest method getIntervals_AcrossWeeks_BeforeIntervalStart.

@Test
public void getIntervals_AcrossWeeks_BeforeIntervalStart() {
    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(3, 0, 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)

Example 3 with ConsecutiveDaysTimeframe

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

the class ConsecutiveDaysTimeframeTest method getIntervals_SameWeek_BeforeIntervalStart.

@Test
public void getIntervals_SameWeek_BeforeIntervalStart() {
    TimeOfDayOfWeek startTimeOfDayOfWeek = new TimeOfDayOfWeek(5, 15, 0, 0);
    TimeOfDayOfWeek endTimeOfDayOfWeek = new TimeOfDayOfWeek(7, 20, 0, 0);
    ConsecutiveDaysTimeframe timeRange = new ConsecutiveDaysTimeframe(startTimeOfDayOfWeek, endTimeOfDayOfWeek);
    LocalDateTime now = toDayOfWeek(1, 0, 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)

Example 4 with ConsecutiveDaysTimeframe

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

the class ConsecutiveDaysTimeframeTest method getIntervals_SameWeek_AfterInterval.

@Test
public void getIntervals_SameWeek_AfterInterval() {
    TimeOfDayOfWeek startTimeOfDayOfWeek = new TimeOfDayOfWeek(5, 15, 0, 0);
    TimeOfDayOfWeek endTimeOfDayOfWeek = new TimeOfDayOfWeek(7, 20, 0, 0);
    ConsecutiveDaysTimeframe timeRange = new ConsecutiveDaysTimeframe(startTimeOfDayOfWeek, endTimeOfDayOfWeek);
    LocalDateTime now = toDayOfWeek(7, 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)

Example 5 with ConsecutiveDaysTimeframe

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

the class ConsecutiveDaysTimeframeTest method getIntervals_SameWeek_WithinInterval.

@Test
public void getIntervals_SameWeek_WithinInterval() {
    TimeOfDayOfWeek startTimeOfDayOfWeek = new TimeOfDayOfWeek(5, 15, 0, 0);
    TimeOfDayOfWeek endTimeOfDayOfWeek = new TimeOfDayOfWeek(7, 20, 0, 0);
    ConsecutiveDaysTimeframe timeRange = new ConsecutiveDaysTimeframe(startTimeOfDayOfWeek, endTimeOfDayOfWeek);
    LocalDateTime now = toDayOfWeek(5, 18, 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