use of de.avanux.smartapplianceenabler.test.TestBuilder in project SmartApplianceEnabler by camueller.
the class IntegrationTest method testSwitchOnBeforeTimeframeIntervalStart.
@Test
public void testSwitchOnBeforeTimeframeIntervalStart() {
String applianceId = "F-001";
TestBuilder builder = new TestBuilder().appliance(applianceId).withMockSwitch(false).withMockMeter().withSchedule(10, 0, 18, 0, 3600, null).init();
Appliance appliance = builder.getAppliance();
Control control = (MockSwitch) appliance.getControl();
RunningTimeMonitor runningTimeMonitor = appliance.getRunningTimeMonitor();
log("Switch on");
LocalDateTime timeSwitchOn = toToday(9, 59, 0);
sempController.em2Device(timeSwitchOn, createEM2Device(applianceId, true));
Assert.assertTrue("It should be possible to set appliance control state to running before " + "the timeframe interval started", runningTimeMonitor.isRunning());
log("Check values right after switch on before interval start");
assertRunningTime(timeSwitchOn, control, runningTimeMonitor, true, true, false, false, null, null, null);
log("Check values after switch on right before interval start");
LocalDateTime timeBeforeIntervalStart = toToday(9, 59, 59);
runningTimeMonitor.updateActiveTimeframeInterval(timeBeforeIntervalStart);
assertRunningTime(timeBeforeIntervalStart, control, runningTimeMonitor, true, true, false, false, null, null, null);
log("Check values after switch on right after interval start");
LocalDateTime timeIntervalStart = toToday(10, 0, 0);
runningTimeMonitor.updateActiveTimeframeInterval(timeIntervalStart);
assertRunningTime(timeIntervalStart, control, runningTimeMonitor, true, true, false, true, 60, 3540, null);
}
Aggregations