Search in sources :

Example 6 with TestBuilder

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);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Control(de.avanux.smartapplianceenabler.control.Control) MockSwitch(de.avanux.smartapplianceenabler.control.MockSwitch) TestBuilder(de.avanux.smartapplianceenabler.test.TestBuilder) Test(org.junit.Test)

Aggregations

TestBuilder (de.avanux.smartapplianceenabler.test.TestBuilder)6 Test (org.junit.Test)6 LocalDateTime (org.joda.time.LocalDateTime)4 Control (de.avanux.smartapplianceenabler.control.Control)3 ApplianceStatus (de.avanux.smartapplianceenabler.webservice.ApplianceStatus)3 MockSwitch (de.avanux.smartapplianceenabler.control.MockSwitch)1 StartingCurrentSwitch (de.avanux.smartapplianceenabler.control.StartingCurrentSwitch)1 Meter (de.avanux.smartapplianceenabler.meter.Meter)1