Search in sources :

Example 86 with LocalDateTime

use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.

the class ConsecutiveDaysTimeframeTest method getIntervals_SameWeek_AfterInterval.

@Test
public void getIntervals_SameWeek_AfterInterval() {
    TimeOfDayOfWeek startTimeOfDayOfWeek = new TimeOfDayOfWeek(5, 15, 0, 0);
    TimeOfDayOfWeek endTimeOfDayOfWeek = new TimeOfDayOfWeek(7, 20, 0, 0);
    ConsecutiveDaysTimeframe timeRange = new ConsecutiveDaysTimeframe(startTimeOfDayOfWeek, endTimeOfDayOfWeek);
    LocalDateTime now = toDayOfWeek(7, 21, 0, 0);
    List<TimeframeInterval> intervals = timeRange.getIntervals(now);
    Assert.assertEquals(1, intervals.size());
    LocalDateTime start = startTimeOfDayOfWeek.toNextOccurrence(now);
    assertDateTime(start, intervals.get(0).getInterval().getStart().toLocalDateTime());
    assertDateTime(endTimeOfDayOfWeek.toNextOccurrence(start), intervals.get(0).getInterval().getEnd().toLocalDateTime());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Test(org.junit.Test)

Example 87 with LocalDateTime

use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.

the class DayTimeframeTest method getIntervals_DayOfWeekNotMatching_WithinInterval.

@Test
public void getIntervals_DayOfWeekNotMatching_WithinInterval() {
    DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(10, 0, 0), new TimeOfDay(12, 0, 0), Collections.singletonList(3));
    LocalDateTime now = toDayOfWeek(3, 11, 0, 0);
    List<TimeframeInterval> intervals = timeframe.getIntervals(now);
    Assert.assertEquals(1, intervals.size());
    Assert.assertEquals(new Interval(toDayOfWeek(now, 3, 10, 0, 0).toDateTime(), toDayOfWeek(now, 3, 12, 0, 0).toDateTime()), intervals.get(0).getInterval());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 88 with LocalDateTime

use of org.joda.time.LocalDateTime in project SmartApplianceEnabler by camueller.

the class DayTimeframeTest method getIntervals_ValidOnlyOnHoliday_HolidaySet.

@Test
public void getIntervals_ValidOnlyOnHoliday_HolidaySet() {
    DayTimeframe timeframe = new DayTimeframe(new TimeOfDay(10, 0, 0), new TimeOfDay(12, 0, 0), Collections.singletonList(8));
    LocalDateTime now = toDayOfWeek(1, 9, 0, 0);
    timeframe.setHolidays(Collections.singletonList(now.toLocalDate()));
    List<TimeframeInterval> intervals = timeframe.getIntervals(now);
    Assert.assertEquals(1, intervals.size());
    Assert.assertEquals(new Interval(toDayOfWeek(now, 1, 10, 0, 0).toDateTime(), toDayOfWeek(now, 1, 12, 0, 0).toDateTime()), intervals.get(0).getInterval());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 89 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) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 90 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) Interval(org.joda.time.Interval) 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