Search in sources :

Example 1 with OwnedIntervalSequence

use of org.opennms.core.utils.OwnedIntervalSequence in project opennms by OpenNMS.

the class TimeIntervalSequenceTest method testExtensionUnscheduled.

@Test
public void testExtensionUnscheduled() throws Exception {
    // seg with three entryies 8-5 on aug 18, aug 19 and aug 20
    OwnedIntervalSequence seq = new OwnedIntervalSequence(ownedOneAndTwo(aug(18, 8, 17)));
    seq.addInterval(ownedOneAndTwo(aug(19, 8, 17)));
    seq.addInterval(ownedOneAndTwo(aug(20, 8, 17)));
    OwnedIntervalSequence unscheduled = new OwnedIntervalSequence(owned(aug(18)));
    unscheduled.removeAll(seq);
    OwnedInterval[] expected = { owned(aug(18, 0, 8)), owned(aug(18, 17, 24)) };
    assertTimeIntervalSequence(expected, unscheduled);
}
Also used : OwnedIntervalSequence(org.opennms.core.utils.OwnedIntervalSequence) OwnedInterval(org.opennms.core.utils.OwnedInterval) Test(org.junit.Test)

Example 2 with OwnedIntervalSequence

use of org.opennms.core.utils.OwnedIntervalSequence in project opennms by OpenNMS.

the class TimeIntervalSequenceTest method testExtensionRemoveAllOwners.

@Test
public void testExtensionRemoveAllOwners() throws Exception {
    // seg with three entryies 8-5 on aug 18, aug 19 and aug 20
    OwnedIntervalSequence seq = new OwnedIntervalSequence(ownedOneAndTwo(aug(18, 8, 17)));
    seq.addInterval(ownedOneAndTwo(aug(19, 8, 17)));
    seq.addInterval(ownedOneAndTwo(aug(20, 8, 17)));
    // now add interval from aug 18 12 to aug 20 24)
    seq.removeInterval(ownedOneAndTwo(aug(18, 12, 20, 13)));
    // expect a sequence containing non overlapping segments
    OwnedInterval[] expected = { ownedOneAndTwo(aug(18, 8, 12)), ownedOneAndTwo(aug(20, 13, 17)) };
    assertTimeIntervalSequence(expected, seq);
}
Also used : OwnedIntervalSequence(org.opennms.core.utils.OwnedIntervalSequence) OwnedInterval(org.opennms.core.utils.OwnedInterval) Test(org.junit.Test)

Example 3 with OwnedIntervalSequence

use of org.opennms.core.utils.OwnedIntervalSequence in project opennms by OpenNMS.

the class BasicScheduleUtilsTest method testSimpleScheduleIncluded.

@Test
public void testSimpleScheduleIncluded() 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);
    Owner owner = new Owner("unnamed", "simple", 0);
    OwnedIntervalSequence intervals = BasicScheduleUtils.getIntervalsCovering(aug(18), BasicScheduleUtils.getGroupSchedule(simpleSchedule), owner);
    assertNotNull(intervals);
    assertTimeIntervalSequence(new OwnedInterval[] { owned(owner, aug(18, 13, 14)) }, intervals);
}
Also used : Owner(org.opennms.core.utils.Owner) Schedule(org.opennms.netmgt.config.groups.Schedule) OwnedIntervalSequence(org.opennms.core.utils.OwnedIntervalSequence) Test(org.junit.Test)

Example 4 with OwnedIntervalSequence

use of org.opennms.core.utils.OwnedIntervalSequence in project opennms by OpenNMS.

the class BasicScheduleUtilsTest method testComplexScheduleIncluded.

@Test
public void testComplexScheduleIncluded() throws Exception {
    String schedSpec = "           <schedule name=\"complex\" type=\"specific\">" + "               <time day=\"thursday\" begins=\"13:00:00\" ends=\"14:00:00\"/>\n" + "               <time day=\"friday\" begins=\"07:00:00\" ends=\"08:00:00\"/>\n" + "               <time day=\"18\" begins=\"19:00:00\" ends=\"20:00:00\"/>\n" + "               <time day=\"19\" begins=\"09:00:00\" ends=\"10:00:00\"/>\n" + "               <time begins=\"18-Aug-2005 16:00:00\" ends=\"18-Aug-2005 17:00:00\"/>\n" + "           </schedule>";
    Schedule simpleSchedule = JaxbUtils.unmarshal(Schedule.class, schedSpec);
    Owner owner = new Owner("unnamed", "complex", 0);
    OwnedIntervalSequence intervals = BasicScheduleUtils.getIntervalsCovering(aug(18), BasicScheduleUtils.getGroupSchedule(simpleSchedule), owner);
    assertNotNull(intervals);
    OwnedInterval[] expected = { owned(owner, aug(18, 13, 14)), owned(owner, aug(18, 16, 17)), owned(owner, aug(18, 19, 20)) };
    assertTimeIntervalSequence(expected, intervals);
}
Also used : Owner(org.opennms.core.utils.Owner) Schedule(org.opennms.netmgt.config.groups.Schedule) OwnedIntervalSequence(org.opennms.core.utils.OwnedIntervalSequence) OwnedInterval(org.opennms.core.utils.OwnedInterval) Test(org.junit.Test)

Example 5 with OwnedIntervalSequence

use of org.opennms.core.utils.OwnedIntervalSequence in project opennms by OpenNMS.

the class BasicScheduleUtilsTest method testDoubleScheduleIncluded.

@Test
public void testDoubleScheduleIncluded() throws Exception {
    String schedSpec = "           <schedule name=\"double\" type=\"specific\">" + "               <time begins=\"18-Aug-2005 13:00:00\" ends=\"18-Aug-2005 14:00:00\"/>\n" + "               <time begins=\"18-Aug-2005 16:00:00\" ends=\"18-Aug-2005 17:00:00\"/>\n" + "           </schedule>";
    Schedule simpleSchedule = JaxbUtils.unmarshal(Schedule.class, schedSpec);
    Owner owner = new Owner("unnamed", "double", 0);
    OwnedIntervalSequence intervals = BasicScheduleUtils.getIntervalsCovering(aug(18), BasicScheduleUtils.getGroupSchedule(simpleSchedule), owner);
    assertNotNull(intervals);
    assertTimeIntervalSequence(new OwnedInterval[] { owned(owner, aug(18, 13, 14)), owned(owner, aug(18, 16, 17)) }, intervals);
}
Also used : Owner(org.opennms.core.utils.Owner) Schedule(org.opennms.netmgt.config.groups.Schedule) OwnedIntervalSequence(org.opennms.core.utils.OwnedIntervalSequence) Test(org.junit.Test)

Aggregations

OwnedIntervalSequence (org.opennms.core.utils.OwnedIntervalSequence)17 Test (org.junit.Test)13 OwnedInterval (org.opennms.core.utils.OwnedInterval)12 Owner (org.opennms.core.utils.Owner)10 Schedule (org.opennms.netmgt.config.groups.Schedule)8 ArrayList (java.util.ArrayList)2 Date (java.util.Date)1 Role (org.opennms.netmgt.config.groups.Role)1 Time (org.opennms.netmgt.config.groups.Time)1 DutySchedule (org.opennms.netmgt.config.users.DutySchedule)1