Search in sources :

Example 1 with Schedule

use of org.opennms.netmgt.config.groups.Schedule 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 2 with Schedule

use of org.opennms.netmgt.config.groups.Schedule 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 3 with Schedule

use of org.opennms.netmgt.config.groups.Schedule 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);
}
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 4 with Schedule

use of org.opennms.netmgt.config.groups.Schedule 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)

Example 5 with Schedule

use of org.opennms.netmgt.config.groups.Schedule in project opennms by OpenNMS.

the class BasicScheduleUtilsTest method testGetIntervalsMonthly.

@Test
public void testGetIntervalsMonthly() throws Exception {
    String schedSpec = "           <schedule name=\"simple\" type=\"monthly\">" + "               <time day=\"7\" 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(interval(6, /* june */
    7, 13, 11, /* nov */
    7, 12), basicSchedule.getTime(0), owner);
    assertNotNull(intervals);
    OwnedInterval[] expected = { owned(owner, jun(7, 13, 14)), owned(owner, jul(7, 11, 14)), owned(owner, aug(7, 11, 14)), owned(owner, sep(7, 11, 14)), owned(owner, oct(7, 11, 14)), owned(owner, nov(7, 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

Schedule (org.opennms.netmgt.config.groups.Schedule)17 Owner (org.opennms.core.utils.Owner)11 Test (org.junit.Test)10 OwnedIntervalSequence (org.opennms.core.utils.OwnedIntervalSequence)8 OwnedInterval (org.opennms.core.utils.OwnedInterval)5 DutySchedule (org.opennms.netmgt.config.users.DutySchedule)5 ArrayList (java.util.ArrayList)3 TimeInterval (org.opennms.core.utils.TimeInterval)3 Role (org.opennms.netmgt.config.groups.Role)3 Time (org.opennms.netmgt.config.groups.Time)3 IOException (java.io.IOException)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 Group (org.opennms.netmgt.config.groups.Group)1 OnmsGroup (org.opennms.netmgt.model.OnmsGroup)1