use of de.avanux.smartapplianceenabler.control.StartingCurrentSwitch in project SmartApplianceEnabler by camueller.
the class IntegrationTest method testSwitchOnAndOff_startingCurrentDetectedDuringTimeframeInterval.
@Test
public void testSwitchOnAndOff_startingCurrentDetectedDuringTimeframeInterval() {
String applianceId = "F-001";
TestBuilder builder = new TestBuilder().appliance(applianceId).withMockSwitch(true).withMockMeter().withSchedule(10, 0, 18, 0, 3600, null).init();
Appliance appliance = builder.getAppliance();
StartingCurrentSwitch control = (StartingCurrentSwitch) appliance.getControl();
Meter meter = appliance.getMeter();
RunningTimeMonitor runningTimeMonitor = appliance.getRunningTimeMonitor();
log("Check initial values");
assertRunningTime(null, control, runningTimeMonitor, false, true, false, false, false, null, null, null);
log("Detect starting current");
LocalDateTime timeBeforeStartingCurrent = toToday(11, 29, 0);
Mockito.when(meter.getAveragePower()).thenReturn(StartingCurrentSwitchDefaults.getPowerThreshold() + 1);
control.detectStartingCurrent(timeBeforeStartingCurrent, meter);
assertRunningTime(timeBeforeStartingCurrent, control, runningTimeMonitor, false, true, false, false, false, null, null, null);
Assert.assertEquals(0, sempController.createDevice2EM(timeBeforeStartingCurrent).getPlanningRequest().size());
LocalDateTime timeStartingCurrent = toToday(11, 30, 0);
control.detectStartingCurrent(toToday(11, 30, 0), meter);
assertRunningTime(timeStartingCurrent, control, runningTimeMonitor, false, false, false, false, true, 0, 3600, null);
assertPlanningRequest(timeStartingCurrent, new Timeframe(applianceId, 0, 23400, 3599, 3600));
log("Switch on");
LocalDateTime timeSwitchOn = toToday(12, 0, 0);
sempController.em2Device(timeSwitchOn, createEM2Device(applianceId, true));
log("Check values after switch on");
assertRunningTime(timeSwitchOn, control, runningTimeMonitor, true, true, true, false, true, 0, 3600, null);
assertPlanningRequest(timeSwitchOn, new Timeframe(applianceId, 0, 21600, 3599, 3600));
ApplianceStatus applianceStatusAfterSwitchOn = getApplianceStatus(timeSwitchOn);
Assert.assertTrue(applianceStatusAfterSwitchOn.isOn());
log("Switch off");
LocalDateTime timeSwitchOff = toToday(13, 0, 0);
sempController.em2Device(timeSwitchOff, createEM2Device(applianceId, false));
log("Check values after switch off");
assertRunningTime(timeSwitchOff, control, runningTimeMonitor, false, true, false, true, true, 3600, 0, null);
Assert.assertEquals(0, sempController.createDevice2EM(timeSwitchOff).getPlanningRequest().size());
// TODO nochmal an/aus schalten
}
use of de.avanux.smartapplianceenabler.control.StartingCurrentSwitch in project SmartApplianceEnabler by camueller.
the class TestBuilder method withMockSwitch.
public TestBuilder withMockSwitch(boolean asStartingCurrentSwitch) {
Control control = new MockSwitch();
if (asStartingCurrentSwitch) {
StartingCurrentSwitch startingCurrentSwitch = new StartingCurrentSwitch();
startingCurrentSwitch.setControl(control);
control = startingCurrentSwitch;
}
getAppliance().setControl(control);
return this;
}
Aggregations