use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.
the class IntegrationTest method testClickGoLight.
@Test
public void testClickGoLight() {
String applianceId = "F-001";
TestBuilder builder = new TestBuilder().appliance(applianceId).withMockSwitch(false).withSchedule(10, 0, 18, 0, 3600, null).init();
Appliance appliance = builder.getAppliance();
Control control = appliance.getControl();
RunningTimeMonitor runningTimeMonitor = appliance.getRunningTimeMonitor();
log("Check initial values");
Assert.assertFalse(control.isOn());
Assert.assertNull(runningTimeMonitor.getActiveTimeframeInterval());
log("Set runtime creates timeframe to be set");
LocalDateTime timeSwitchOn = toToday(11, 0, 0);
Assert.assertEquals(3600, saeController.suggestRuntime(applianceId).intValue());
saeController.setRuntime(timeSwitchOn, applianceId, 1800);
Assert.assertNotNull(runningTimeMonitor.getActiveTimeframeInterval());
log("Switch on");
sempController.em2Device(timeSwitchOn, createEM2Device(applianceId, true));
log("Check values after switch on");
assertRunningTime(timeSwitchOn, control, runningTimeMonitor, true, true, false, 0, 1800, null);
assertPlanningRequest(timeSwitchOn, new Timeframe(applianceId, 0, 1800, 1799, 1800), new Timeframe(applianceId, add24h(-3600), add24h(25200), 3599, 3600), new Timeframe(applianceId, add48h(-3600), add48h(25200), 3599, 3600));
ApplianceStatus applianceStatusAfterSwitchOn = getApplianceStatus(timeSwitchOn);
Assert.assertTrue(applianceStatusAfterSwitchOn.isOn());
log("Update timeframe intervals right after min running time is reached");
log("Timeframe interval created is deactivated and timeframe interval of schedule is activated");
LocalDateTime timeAfterExpiration = toToday(11, 30, 1);
runningTimeMonitor.updateActiveTimeframeInterval(timeAfterExpiration);
log("Check values after expiration");
assertRunningTime(timeAfterExpiration, control, runningTimeMonitor, false, false, false, 0, 3600, null);
assertPlanningRequest(timeAfterExpiration, new Timeframe(applianceId, 0, 23399, 3599, 3600), new Timeframe(applianceId, add24h(-5401), add24h(23399), 3599, 3600), new Timeframe(applianceId, add48h(-5401), add48h(23399), 3599, 3600));
ApplianceStatus applianceStatusAfterSwitchOff = getApplianceStatus(timeAfterExpiration);
Assert.assertFalse(applianceStatusAfterSwitchOff.isOn());
}
use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.
the class HttpSwitchTest method on_SonoffPow.
@Ignore
@Test
public void on_SonoffPow() {
zwitch.setOnUrl("http://192.168.69.62/cm?cmnd=Power%20On");
zwitch.on(new LocalDateTime(), true);
}
use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.
the class HttpSwitchTest method on_EdimaxSP2101W.
@Ignore
@Test
public void on_EdimaxSP2101W() {
zwitch.setOnUrl("http://192.168.69.74:10000/smartplug.cgi");
zwitch.setUsername("admin");
zwitch.setPassword("12345678");
zwitch.setContentType("application/xml");
zwitch.setOnData("<?xml version=\"1.0\" encoding=\"UTF8\"?><SMARTPLUG id=\"edimax\"><CMD id=\"setup\"><Device.System.Power.State>ON</Device.System.Power.State></CMD></SMARTPLUG>");
zwitch.on(new LocalDateTime(), true);
}
use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.
the class DayTimeframeTest method getIntervals_ValidOnSundayAndHoliday_HolidayIsSunday.
@Test
public void getIntervals_ValidOnSundayAndHoliday_HolidayIsSunday() {
DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(10, 0, 0), new TimeOfDay(12, 0, 0), Arrays.asList(7, 8));
LocalDateTime now = toDayOfWeek(1, 9, 0, 0);
timeframe.setHolidays(Collections.singletonList(now.toLocalDate().plusDays(6)));
List<TimeframeInterval> intervals = timeframe.getIntervals(now);
Assert.assertEquals(1, intervals.size());
Assert.assertEquals(new Interval(toDayOfWeek(now, 7, 10, 0, 0).toDateTime(), toDayOfWeek(now, 7, 12, 0, 0).toDateTime()), intervals.get(0).getInterval());
}
use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.
the class DayTimeframeTest method getIntervals_ValidOnSundayAndHoliday_HolidayIsThursday.
@Test
public void getIntervals_ValidOnSundayAndHoliday_HolidayIsThursday() {
DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(10, 0, 0), new TimeOfDay(12, 0, 0), Arrays.asList(7, 8));
LocalDateTime now = toDayOfWeek(1, 9, 0, 0);
timeframe.setHolidays(Collections.singletonList(now.toLocalDate().plusDays(3)));
List<TimeframeInterval> intervals = timeframe.getIntervals(now);
Assert.assertEquals(2, intervals.size());
Assert.assertEquals(new Interval(toDayOfWeek(now, 4, 10, 0, 0).toDateTime(), toDayOfWeek(now, 4, 12, 0, 0).toDateTime()), intervals.get(0).getInterval());
Assert.assertEquals(new Interval(toDayOfWeek(now, 7, 10, 0, 0).toDateTime(), toDayOfWeek(now, 7, 12, 0, 0).toDateTime()), intervals.get(1).getInterval());
}
Aggregations