Search in sources :

Example 1 with DayTimeframe

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

the class DayTimeframeTest method buildMidnightAdjustedInterval_OverMidnight_AfterInterval_AfterMidnight.

@Test
public void buildMidnightAdjustedInterval_OverMidnight_AfterInterval_AfterMidnight() {
    DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(22, 0, 0), new TimeOfDay(2, 0, 0));
    Interval interval = timeframe.buildMidnightAdjustedInterval(toToday(3, 0, 0));
    Assert.assertEquals(new Interval(toToday(22, 0, 0).toDateTime(), toDay(1, 2, 0, 0).toDateTime()), interval);
}
Also used : TimeOfDay(de.avanux.smartapplianceenabler.schedule.TimeOfDay) DayTimeframe(de.avanux.smartapplianceenabler.schedule.DayTimeframe) Interval(org.joda.time.Interval) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) Test(org.junit.Test)

Example 2 with DayTimeframe

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

the class DayTimeframeTest method buildMidnightAdjustedInterval_OverMidnight_WithinInterval_AfterMidnight.

@Test
public void buildMidnightAdjustedInterval_OverMidnight_WithinInterval_AfterMidnight() {
    DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(22, 0, 0), new TimeOfDay(2, 0, 0));
    Interval interval = timeframe.buildMidnightAdjustedInterval(toToday(1, 0, 0));
    Assert.assertEquals(new Interval(toDay(-1, 22, 0, 0).toDateTime(), toToday(2, 0, 0).toDateTime()), interval);
}
Also used : TimeOfDay(de.avanux.smartapplianceenabler.schedule.TimeOfDay) DayTimeframe(de.avanux.smartapplianceenabler.schedule.DayTimeframe) Interval(org.joda.time.Interval) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) Test(org.junit.Test)

Example 3 with DayTimeframe

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

the class DayTimeframeTest method getIntervals_AllDayOfWeek_WithinInterval.

@Test
public void getIntervals_AllDayOfWeek_WithinInterval() {
    DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(10, 0, 0), new TimeOfDay(12, 0, 0));
    List<TimeframeInterval> intervals = timeframe.getIntervals(toToday(11, 0, 0));
    Assert.assertEquals(7, intervals.size());
    Assert.assertEquals(new Interval(toToday(10, 0, 0).toDateTime(), toToday(12, 0, 0).toDateTime()), intervals.get(0).getInterval());
    Assert.assertEquals(new Interval(toDay(1, 10, 0, 0).toDateTime(), toDay(1, 12, 0, 0).toDateTime()), intervals.get(1).getInterval());
    Assert.assertEquals(new Interval(toDay(2, 10, 0, 0).toDateTime(), toDay(2, 12, 0, 0).toDateTime()), intervals.get(2).getInterval());
    Assert.assertEquals(new Interval(toDay(3, 10, 0, 0).toDateTime(), toDay(3, 12, 0, 0).toDateTime()), intervals.get(3).getInterval());
    Assert.assertEquals(new Interval(toDay(4, 10, 0, 0).toDateTime(), toDay(4, 12, 0, 0).toDateTime()), intervals.get(4).getInterval());
    Assert.assertEquals(new Interval(toDay(5, 10, 0, 0).toDateTime(), toDay(5, 12, 0, 0).toDateTime()), intervals.get(5).getInterval());
    Assert.assertEquals(new Interval(toDay(6, 10, 0, 0).toDateTime(), toDay(6, 12, 0, 0).toDateTime()), intervals.get(6).getInterval());
}
Also used : TimeOfDay(de.avanux.smartapplianceenabler.schedule.TimeOfDay) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) DayTimeframe(de.avanux.smartapplianceenabler.schedule.DayTimeframe) Interval(org.joda.time.Interval) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) Test(org.junit.Test)

Example 4 with DayTimeframe

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

the class DayTimeframeTest method buildMidnightAdjustedInterval_NotOverMidnight.

@Test
public void buildMidnightAdjustedInterval_NotOverMidnight() {
    DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(22, 0, 0), new TimeOfDay(23, 0, 0));
    Interval interval = timeframe.buildMidnightAdjustedInterval(toToday(9, 0, 0));
    Assert.assertEquals(new Interval(toToday(22, 0, 0).toDateTime(), toToday(23, 0, 0).toDateTime()), interval);
}
Also used : TimeOfDay(de.avanux.smartapplianceenabler.schedule.TimeOfDay) DayTimeframe(de.avanux.smartapplianceenabler.schedule.DayTimeframe) Interval(org.joda.time.Interval) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) Test(org.junit.Test)

Example 5 with DayTimeframe

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

the class DayTimeframeTest method getIntervals_AllDayOfWeek_BeforeIntervalStart.

@Test
public void getIntervals_AllDayOfWeek_BeforeIntervalStart() {
    DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(10, 0, 0), new TimeOfDay(12, 0, 0));
    List<TimeframeInterval> intervals = timeframe.getIntervals(toToday(9, 0, 0));
    Assert.assertEquals(7, intervals.size());
    Assert.assertEquals(new Interval(toToday(10, 0, 0).toDateTime(), toToday(12, 0, 0).toDateTime()), intervals.get(0).getInterval());
    Assert.assertEquals(new Interval(toDay(1, 10, 0, 0).toDateTime(), toDay(1, 12, 0, 0).toDateTime()), intervals.get(1).getInterval());
    Assert.assertEquals(new Interval(toDay(2, 10, 0, 0).toDateTime(), toDay(2, 12, 0, 0).toDateTime()), intervals.get(2).getInterval());
    Assert.assertEquals(new Interval(toDay(3, 10, 0, 0).toDateTime(), toDay(3, 12, 0, 0).toDateTime()), intervals.get(3).getInterval());
    Assert.assertEquals(new Interval(toDay(4, 10, 0, 0).toDateTime(), toDay(4, 12, 0, 0).toDateTime()), intervals.get(4).getInterval());
    Assert.assertEquals(new Interval(toDay(5, 10, 0, 0).toDateTime(), toDay(5, 12, 0, 0).toDateTime()), intervals.get(5).getInterval());
    Assert.assertEquals(new Interval(toDay(6, 10, 0, 0).toDateTime(), toDay(6, 12, 0, 0).toDateTime()), intervals.get(6).getInterval());
}
Also used : TimeOfDay(de.avanux.smartapplianceenabler.schedule.TimeOfDay) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) DayTimeframe(de.avanux.smartapplianceenabler.schedule.DayTimeframe) Interval(org.joda.time.Interval) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) Test(org.junit.Test)

Aggregations

DayTimeframe (de.avanux.smartapplianceenabler.schedule.DayTimeframe)8 TimeOfDay (de.avanux.smartapplianceenabler.schedule.TimeOfDay)8 TimeframeInterval (de.avanux.smartapplianceenabler.schedule.TimeframeInterval)8 Interval (org.joda.time.Interval)8 Test (org.junit.Test)8