Search in sources :

Example 1 with MockSwitch

use of de.avanux.smartapplianceenabler.control.MockSwitch 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;
}
Also used : Control(de.avanux.smartapplianceenabler.control.Control) StartingCurrentSwitch(de.avanux.smartapplianceenabler.control.StartingCurrentSwitch) MockSwitch(de.avanux.smartapplianceenabler.control.MockSwitch)

Example 2 with MockSwitch

use of de.avanux.smartapplianceenabler.control.MockSwitch 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

Control (de.avanux.smartapplianceenabler.control.Control)2 MockSwitch (de.avanux.smartapplianceenabler.control.MockSwitch)2 StartingCurrentSwitch (de.avanux.smartapplianceenabler.control.StartingCurrentSwitch)1 TestBuilder (de.avanux.smartapplianceenabler.test.TestBuilder)1 LocalDateTime (org.joda.time.LocalDateTime)1 Test (org.junit.Test)1