use of org.opennms.core.utils.TimeInterval in project opennms by OpenNMS.
the class TimeIntervalSequenceTest method testRemoveOverlappingMany.
@Test
public void testRemoveOverlappingMany() throws Exception {
TimeIntervalSequence seq = new TimeIntervalSequence(aug(18, 8, 17));
seq.addInterval(aug(19, 8, 17));
seq.addInterval(aug(20, 8, 17));
seq.addInterval(aug(21, 8, 17));
seq.addInterval(aug(22, 8, 17));
// remove a large interval
seq.removeInterval(aug(19, 12, 21, 12));
// expect a sequence containing non overlapping segments
TimeInterval[] expected = { aug(18, 8, 17), aug(19, 8, 12), aug(21, 12, 17), aug(22, 8, 17) };
assertTimeIntervalSequence(expected, seq);
}
use of org.opennms.core.utils.TimeInterval in project opennms by OpenNMS.
the class BasicScheduleUtilsTest method testWeeklyInterval.
@Test
public void testWeeklyInterval() throws Exception {
String schedSpec = " <schedule name=\"simple\" type=\"specific\">" + " <time day=\"thursday\" begins=\"13:00:00\" ends=\"14:00:00\"/>\n" + " </schedule>";
Schedule simpleSchedule = JaxbUtils.unmarshal(Schedule.class, schedSpec);
BasicSchedule basicSchedule = BasicScheduleUtils.getGroupSchedule(simpleSchedule);
Owner owner = new Owner("unnamed", "simple", 0, 0);
TimeInterval interval = BasicScheduleUtils.getInterval(aug(18).getStart(), basicSchedule.getTime(0), owner);
assertNotNull(interval);
assertInterval(owned(owner, aug(18, 13, 14)), interval);
}
use of org.opennms.core.utils.TimeInterval in project opennms by OpenNMS.
the class BasicScheduleUtilsTest method testSpecificInterval.
@Test
public void testSpecificInterval() throws Exception {
String schedSpec = " <schedule name=\"simple\" type=\"specific\">" + " <time begins=\"18-Aug-2005 13:00:00\" ends=\"18-Aug-2005 14:00:00\"/>\n" + " </schedule>";
Schedule simpleSchedule = JaxbUtils.unmarshal(Schedule.class, schedSpec);
BasicSchedule basicSchedule = BasicScheduleUtils.getGroupSchedule(simpleSchedule);
Owner owner = new Owner("unnamed", "simple", 0, 0);
TimeInterval interval = BasicScheduleUtils.getInterval(new Date(), basicSchedule.getTime(0), owner);
assertNotNull(interval);
assertInterval(owned(owner, aug(18, 13, 14)), interval);
}
Aggregations