use of de.avanux.smartapplianceenabler.schedule.TimeframeInterval in project SmartApplianceEnabler by camueller.
the class ApplianceTest method getRuntimeRequest_TimeFrameAlreadyStartedAndActive_NotSufficient.
@Test
public void getRuntimeRequest_TimeFrameAlreadyStartedAndActive_NotSufficient() {
int nowSeconds = 10;
LocalDateTime now = toToday(11, 0, nowSeconds);
Schedule schedule = new Schedule(3600, null, new TimeOfDay(8, 0, 0), new TimeOfDay(12, 0, 0));
TimeframeInterval activeTimeframeInterval = schedule.getTimeframe().getIntervals(now).get(0);
List<RuntimeRequest> runtimeRequests = this.appliance.getRuntimeRequests(now, Collections.singletonList(schedule), activeTimeframeInterval, true, 3600 - nowSeconds, null);
Assert.assertEquals(3, runtimeRequests.size());
Assert.assertEquals(new RuntimeRequest(0, 3600 - nowSeconds, 3600 - nowSeconds, null), runtimeRequests.get(0));
Assert.assertEquals(new RuntimeRequest(75600 - nowSeconds, 90000 - nowSeconds, 3600, null), runtimeRequests.get(1));
Assert.assertEquals(new RuntimeRequest(162000 - nowSeconds, 176400 - nowSeconds, 3600, null), runtimeRequests.get(2));
}
use of de.avanux.smartapplianceenabler.schedule.TimeframeInterval in project SmartApplianceEnabler by camueller.
the class RunningTimeMonitor method activateTimeframeInterval.
public void activateTimeframeInterval(LocalDateTime now, Integer runtime) {
activeTimeframeInterval = null;
Schedule schedule = new Schedule(runtime, null, new TimeOfDay(now), new TimeOfDay(now));
Interval interval = new Interval(now.toDateTime(), now.plusSeconds(runtime).toDateTime());
Timeframe timeframe = schedule.getTimeframe();
activateTimeframeInterval(now, new TimeframeInterval(timeframe, interval));
}
use of de.avanux.smartapplianceenabler.schedule.TimeframeInterval 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());
}
use of de.avanux.smartapplianceenabler.schedule.TimeframeInterval 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());
}
use of de.avanux.smartapplianceenabler.schedule.TimeframeInterval in project SmartApplianceEnabler by camueller.
the class DayTimeframeTest method getIntervals_DayOfWeekNotMatching_BeforeIntervalStart.
@Test
public void getIntervals_DayOfWeekNotMatching_BeforeIntervalStart() {
DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(10, 0, 0), new TimeOfDay(12, 0, 0), Collections.singletonList(3));
LocalDateTime now = toDayOfWeek(1, 9, 0, 0);
List<TimeframeInterval> intervals = timeframe.getIntervals(now);
Assert.assertEquals(1, intervals.size());
Assert.assertEquals(new Interval(toDayOfWeek(now, 3, 10, 0, 0).toDateTime(), toDayOfWeek(now, 3, 12, 0, 0).toDateTime()), intervals.get(0).getInterval());
}
Aggregations