Search in sources :

Example 11 with Owner

use of org.opennms.core.utils.Owner 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);
}
Also used : Owner(org.opennms.core.utils.Owner) TimeInterval(org.opennms.core.utils.TimeInterval) Schedule(org.opennms.netmgt.config.groups.Schedule) Test(org.junit.Test)

Example 12 with Owner

use of org.opennms.core.utils.Owner 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);
}
Also used : Owner(org.opennms.core.utils.Owner) TimeInterval(org.opennms.core.utils.TimeInterval) Schedule(org.opennms.netmgt.config.groups.Schedule) Date(java.util.Date) Test(org.junit.Test)

Example 13 with Owner

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

the class BasicScheduleUtilsTest method testSimpleScheduleExcluded.

@Test
public void testSimpleScheduleExcluded() throws Exception {
    String schedSpec = "           <schedule name=\"simple\" type=\"specific\">" + "               <time begins=\"20-Aug-2005 13:00:00\" ends=\"20-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[0], 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 14 with Owner

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

the class BasicScheduleUtilsTest method testGetIntervalsWeekly.

@Test
public void testGetIntervalsWeekly() throws Exception {
    String schedSpec = "           <schedule name=\"simple\" type=\"weekly\">" + "               <time day=\"thursday\" begins=\"11: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);
    OwnedIntervalSequence intervals = BasicScheduleUtils.getIntervals(aug(4, 13, 25, 12), basicSchedule.getTime(0), owner);
    assertNotNull(intervals);
    OwnedInterval[] expected = { // start of requested interval overlaps this one
    owned(owner, aug(4, 13, 14)), owned(owner, aug(11, 11, 14)), owned(owner, aug(18, 11, 14)), // end of requested interval overlaps this one
    owned(owner, aug(25, 11, 12)) };
    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)

Aggregations

Owner (org.opennms.core.utils.Owner)14 Test (org.junit.Test)11 Schedule (org.opennms.netmgt.config.groups.Schedule)11 OwnedIntervalSequence (org.opennms.core.utils.OwnedIntervalSequence)10 OwnedInterval (org.opennms.core.utils.OwnedInterval)6 TimeInterval (org.opennms.core.utils.TimeInterval)3 ArrayList (java.util.ArrayList)1 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