Search in sources :

Example 51 with LocalDateTime

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

Example 52 with LocalDateTime

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);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 53 with LocalDateTime

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);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 54 with LocalDateTime

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());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) TimeOfDay(de.avanux.smartapplianceenabler.schedule.TimeOfDay) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) DayTimeframe(de.avanux.smartapplianceenabler.schedule.DayTimeframe) Interval(org.joda.time.Interval) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) Test(org.junit.Test)

Example 55 with LocalDateTime

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());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) TimeOfDay(de.avanux.smartapplianceenabler.schedule.TimeOfDay) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) DayTimeframe(de.avanux.smartapplianceenabler.schedule.DayTimeframe) Interval(org.joda.time.Interval) TimeframeInterval(de.avanux.smartapplianceenabler.schedule.TimeframeInterval) Test(org.junit.Test)

Aggregations

LocalDateTime (org.joda.time.LocalDateTime)120 Test (org.junit.Test)73 Interval (org.joda.time.Interval)27 TimeframeInterval (de.avanux.smartapplianceenabler.schedule.TimeframeInterval)21 DateTime (org.joda.time.DateTime)18 TimeOfDay (de.avanux.smartapplianceenabler.schedule.TimeOfDay)17 Schedule (de.avanux.smartapplianceenabler.schedule.Schedule)12 LocalDate (org.joda.time.LocalDate)12 ArrayList (java.util.ArrayList)8 ConsecutiveDaysTimeframe (de.avanux.smartapplianceenabler.schedule.ConsecutiveDaysTimeframe)6 DayTimeframe (de.avanux.smartapplianceenabler.schedule.DayTimeframe)6 TimeOfDayOfWeek (de.avanux.smartapplianceenabler.schedule.TimeOfDayOfWeek)6 Date (java.util.Date)6 TestBuilder (de.avanux.smartapplianceenabler.test.TestBuilder)4 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)4 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)4 AccAccount (eu.bcvsolutions.idm.acc.entity.AccAccount)4 IdmAuthorizationPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto)4 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)4 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4