use of org.opennms.reporting.core.DeliveryOptions in project opennms by OpenNMS.
the class DefaultSchedulerServiceIT method testExecuteFailure.
@Test
public void testExecuteFailure() throws InterruptedException {
expect(m_reportWrapperService.validate(m_criteria, REPORT_ID)).andReturn(false);
replay(m_reportWrapperService);
MockRequestContext context = new MockRequestContext();
DeliveryOptions deliveryOptions = new DeliveryOptions();
deliveryOptions.setInstanceId("testExecuteFailureTrigger");
assertEquals("error", m_schedulerService.execute(REPORT_ID, m_criteria, deliveryOptions, context));
// give the trigger a chance to fire
Thread.sleep(1000);
verify(m_reportWrapperService);
}
use of org.opennms.reporting.core.DeliveryOptions in project opennms by OpenNMS.
the class DefaultSchedulerServiceIT method testExists.
@Test
public void testExists() {
expect(m_reportWrapperService.validate(m_criteria, REPORT_ID)).andReturn(true);
replay(m_reportWrapperService);
MockRequestContext context = new MockRequestContext();
DeliveryOptions deliveryOptions = new DeliveryOptions();
deliveryOptions.setInstanceId("testExistsTrigger");
assertEquals("success", m_schedulerService.addCronTrigger(REPORT_ID, m_criteria, deliveryOptions, CRON_EXPRESSION, context));
verify(m_reportWrapperService);
assertTrue(m_schedulerService.exists("testExistsTrigger"));
assertFalse(m_schedulerService.exists("bogusTrigger"));
m_schedulerService.removeTrigger("testExistsTrigger");
}
use of org.opennms.reporting.core.DeliveryOptions in project opennms by OpenNMS.
the class DefaultSchedulerServiceIT method testGetTriggerDescriptions.
@Test
public void testGetTriggerDescriptions() {
expect(m_reportWrapperService.validate(m_criteria, REPORT_ID)).andReturn(true);
replay(m_reportWrapperService);
MockRequestContext context = new MockRequestContext();
DeliveryOptions deliveryOptions = new DeliveryOptions();
deliveryOptions.setInstanceId("testGetTriggerDescriptionsTrigger");
assertEquals("success", m_schedulerService.addCronTrigger(REPORT_ID, m_criteria, deliveryOptions, CRON_EXPRESSION, context));
verify(m_reportWrapperService);
assertEquals(1, m_schedulerService.getTriggerDescriptions().size());
assertEquals("testGetTriggerDescriptionsTrigger", m_schedulerService.getTriggerDescriptions().get(0).getTriggerName());
m_schedulerService.removeTrigger("testGetTriggerDescriptionsTrigger");
}
use of org.opennms.reporting.core.DeliveryOptions in project opennms by OpenNMS.
the class DefaultSchedulerServiceIT method testMultipleTriggers.
@Test
public void testMultipleTriggers() throws SchedulerException {
expect(m_reportWrapperService.validate(m_criteria, REPORT_ID)).andReturn(true).times(2);
replay(m_reportWrapperService);
MockRequestContext context = new MockRequestContext();
// this trigger fires every 10 minutes starting at 0 minutes past the hour
DeliveryOptions deliveryOptions1 = new DeliveryOptions();
deliveryOptions1.setInstanceId("trigger1");
assertEquals("success", m_schedulerService.addCronTrigger(REPORT_ID, m_criteria, deliveryOptions1, "0 0/10 * * * ?", context));
// this trigger fires every 10 minutes starting at 5 minutes past the hour
DeliveryOptions deliveryOptions2 = new DeliveryOptions();
deliveryOptions2.setInstanceId("trigger2");
assertEquals("success", m_schedulerService.addCronTrigger(REPORT_ID, m_criteria, deliveryOptions2, "0 5/10 * * * ?", context));
verify(m_reportWrapperService);
final List<String> triggers = m_scheduler.getTriggerKeys(GroupMatcher.<TriggerKey>groupEquals(TRIGGER_GROUP)).stream().map(TriggerKey::getName).collect(Collectors.toList());
assertEquals(2, triggers.size());
assertTrue(triggers.contains("trigger1"));
assertTrue(triggers.contains("trigger2"));
m_schedulerService.removeTrigger("trigger1");
m_schedulerService.removeTrigger("trigger2");
assertEquals(0, m_scheduler.getTriggerKeys(GroupMatcher.<TriggerKey>groupEquals(TRIGGER_GROUP)).size());
}
Aggregations