use of de.avanux.smartapplianceenabler.schedule.Schedule in project SmartApplianceEnabler by camueller.
the class ScheduleTest method findTimeframeIntervals_multipleSchedules_differentDaysOfWeek.
@Test
public void findTimeframeIntervals_multipleSchedules_differentDaysOfWeek() {
List<Schedule> schedules = new ArrayList<Schedule>();
addSchedule(schedules, 3600, 10, 0, 12, 0, dowList(3));
addSchedule(schedules, 3600, 12, 0, 14, 0, dowList(2, 4));
addSchedule(schedules, 3600, 14, 0, 16, 0, dowList(1, 5));
LocalDateTime now = toDayOfWeek(1, 9, 0);
List<TimeframeInterval> timeframeIntervals = Schedule.findTimeframeIntervals(now, null, schedules, false, true);
Assert.assertEquals(5, timeframeIntervals.size());
Assert.assertEquals(toIntervalByDow(now, 1, 14, 0, 1, 16, 0), timeframeIntervals.get(0).getInterval());
Assert.assertEquals(toIntervalByDow(now, 2, 12, 0, 2, 14, 0), timeframeIntervals.get(1).getInterval());
Assert.assertEquals(toIntervalByDow(now, 3, 10, 0, 3, 12, 0), timeframeIntervals.get(2).getInterval());
Assert.assertEquals(toIntervalByDow(now, 4, 12, 0, 4, 14, 0), timeframeIntervals.get(3).getInterval());
Assert.assertEquals(toIntervalByDow(now, 5, 14, 0, 5, 16, 0), timeframeIntervals.get(4).getInterval());
}
use of de.avanux.smartapplianceenabler.schedule.Schedule in project SmartApplianceEnabler by camueller.
the class TestBuilder method withSchedule.
public TestBuilder withSchedule(int startHour, int startMinute, int endHour, int endMinute, int minRunningTime, Integer maxRunningTime) {
List<Schedule> schedules = getAppliance().getSchedules();
if (schedules == null) {
schedules = new ArrayList<>();
getAppliance().setSchedules(schedules);
}
schedules.add(new Schedule(minRunningTime, maxRunningTime, new TimeOfDay(startHour, startMinute, 0), new TimeOfDay(endHour, endMinute, 0)));
return this;
}
use of de.avanux.smartapplianceenabler.schedule.Schedule 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.Schedule in project SmartApplianceEnabler by camueller.
the class ApplianceTest method createRuntimeRequest_TimeFrameOverMidnight_AfterMidnight.
@Test
public void createRuntimeRequest_TimeFrameOverMidnight_AfterMidnight() {
LocalDateTime now = toToday(0, 30, 0);
Schedule schedule = new Schedule(7200, null, new TimeOfDay(20, 0, 0), new TimeOfDay(4, 0, 0));
Interval interval = schedule.getTimeframe().getIntervals(now).get(0).getInterval();
RuntimeRequest runtimeRequest = this.appliance.createRuntimeRequest(interval, schedule.getMinRunningTime(), null, now);
Assert.assertEquals(0, (int) runtimeRequest.getEarliestStart());
Assert.assertEquals(12600, (int) runtimeRequest.getLatestEnd());
Assert.assertEquals(7200, (int) runtimeRequest.getMinRunningTime());
Assert.assertNull(runtimeRequest.getMaxRunningTime());
}
use of de.avanux.smartapplianceenabler.schedule.Schedule in project SmartApplianceEnabler by camueller.
the class ApplianceTest method createRuntimeRequest.
@Test
public void createRuntimeRequest() {
LocalDateTime now = toToday(0, 30, 0);
Schedule schedule = new Schedule(7200, null, new TimeOfDay(1, 0, 0), new TimeOfDay(9, 0, 0));
Interval interval = schedule.getTimeframe().getIntervals(now).get(0).getInterval();
schedule.getTimeframe().setSchedule(schedule);
RuntimeRequest runtimeRequest = this.appliance.createRuntimeRequest(interval, schedule.getMinRunningTime(), null, now);
Assert.assertEquals(1800, (int) runtimeRequest.getEarliestStart());
Assert.assertEquals(30600, (int) runtimeRequest.getLatestEnd());
Assert.assertEquals(7200, (int) runtimeRequest.getMinRunningTime());
Assert.assertNull(runtimeRequest.getMaxRunningTime());
}
Aggregations