use of org.opennms.core.utils.TimeInterval in project opennms by OpenNMS.
the class TimeIntervalSequenceTest method testPreceeds.
@Test
public void testPreceeds() throws Exception {
TimeInterval first = new TimeInterval(new Date(0), date("18-08-2005 00:00:00"));
TimeInterval second = aug(18);
assertTrue(first.preceeds(second));
assertFalse(second.preceeds(first));
}
use of org.opennms.core.utils.TimeInterval in project opennms by OpenNMS.
the class TimeIntervalSequenceTest method testAddOverlappingMany.
@Test
public void testAddOverlappingMany() throws Exception {
// seg with three entryies 8-5 on aug 18, aug 19 and aug 20
TimeIntervalSequence seq = new TimeIntervalSequence(aug(18, 8, 17));
seq.addInterval(aug(19, 8, 17));
seq.addInterval(aug(20, 8, 17));
// now add interval from aug 18 0 to aug 20 24)
seq.addInterval(aug(18, 0, 20, 24));
// expect a sequence containing non overlapping segments
TimeInterval[] expected = { aug(18, 0, 8), aug(18, 8, 17), aug(18, 17, 19, 8), aug(19, 8, 17), aug(19, 17, 20, 8), aug(20, 8, 17), aug(20, 17, 24) };
assertTimeIntervalSequence(expected, seq);
}
use of org.opennms.core.utils.TimeInterval in project opennms by OpenNMS.
the class TimeIntervalSequenceTest method testBound.
@Test
public void testBound() 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));
// bound the sequence to the interval aug19 noon to aug 21 noon
seq.bound(aug(19, 12, 21, 12));
// expect a sequence containing non overlapping segments
TimeInterval[] expected = { aug(19, 12, 17), aug(20, 8, 17), aug(21, 8, 12) };
assertTimeIntervalSequence(expected, seq);
}
use of org.opennms.core.utils.TimeInterval in project opennms by OpenNMS.
the class BasicScheduleUtilsTest method testMonthlyInterval.
@Test
public void testMonthlyInterval() throws Exception {
String schedSpec = " <schedule name=\"simple\" type=\"specific\">" + " <time day=\"18\" 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 TimeIntervalSequenceTest method testFollows.
@Test
public void testFollows() throws Exception {
TimeInterval first = new TimeInterval(new Date(0), date("18-08-2005 00:00:00"));
TimeInterval second = aug(18);
assertTrue(second.follows(first));
assertFalse(first.follows(second));
}
Aggregations