use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class TestSLAEmailEventListener method testInvalidDestAddress.
public void testInvalidDestAddress() throws Exception {
String id = "0000000-000000000000001-oozie-wrkf-C@1";
SLACalcStatus event = _createSLACalcStatus(id);
SLARegistrationBean eventBean = event.getSLARegistrationBean();
Date startDate = DateUtils.parseDateUTC("2013-01-01T00:00Z");
// set invalid address as alert contact
eventBean.setAlertContact("invalidAddress");
event.setEventStatus(EventStatus.START_MISS);
event.setId(id);
eventBean.setAppType(AppType.COORDINATOR_ACTION);
eventBean.setAppName("Test-SLA-Start-Miss");
eventBean.setUser("dummyuser");
eventBean.setExpectedStart(startDate);
eventBean.setNotificationMsg("notification of start miss");
eventBean.setAppType(AppType.COORDINATOR_ACTION);
event.setActualStart(DateUtils.parseDateUTC("2013-01-01T01:00Z"));
slaEmailListener.onStartMiss(event);
MimeMessage[] msgs = greenMail.getReceivedMessages();
assertEquals(msgs.length, 0);
}
use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class TestSLAEmailEventListener method testMultipleDestAddress.
public void testMultipleDestAddress() throws Exception {
String id = "0000000-000000000000001-oozie-wrkf-C@1";
SLACalcStatus event = _createSLACalcStatus(id);
SLARegistrationBean eventBean = event.getSLARegistrationBean();
Date startDate = DateUtils.parseDateUTC("2013-01-01T00:00Z");
// set multiple addresses as alert contact
eventBean.setAlertContact("alert-receiver1@oozie.com, alert-receiver2@oozie.com");
event.setEventStatus(EventStatus.START_MISS);
event.setId(id);
eventBean.setAppType(AppType.COORDINATOR_ACTION);
eventBean.setAppName("Test-SLA-Start-Miss");
eventBean.setUser("dummyuser");
eventBean.setExpectedStart(startDate);
eventBean.setNotificationMsg("notification of start miss");
eventBean.setAppType(AppType.COORDINATOR_ACTION);
event.setActualStart(DateUtils.parseDateUTC("2013-01-01T01:00Z"));
slaEmailListener.onStartMiss(event);
MimeMessage[] msgs = greenMail.getReceivedMessages();
MimeMessage msg = msgs[0];
assertEquals(msg.getFrom()[0].toString(), "oozie@localhost");
assertEquals(msg.getRecipients(RecipientType.TO)[0].toString(), "alert-receiver1@oozie.com");
assertEquals(msg.getRecipients(RecipientType.TO)[1].toString(), "alert-receiver2@oozie.com");
}
use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class TestSLARegistrationGetJPAExecutor method testSLARegistrationGet.
public void testSLARegistrationGet() throws Exception {
Date current = new Date();
final String jobId = "0000000-" + current.getTime() + "-TestSLARegGetJPAExecutor-W";
_addRecordToSLARegistrationTable(jobId, AppType.WORKFLOW_JOB, current, new Date(), "END_MISS", "alert@example.com");
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
SLARegistrationBean bean = SLARegistrationQueryExecutor.getInstance().get(SLARegQuery.GET_SLA_REG_ALL, jobId);
assertEquals(jobId, bean.getId());
assertEquals(AppType.WORKFLOW_JOB, bean.getAppType());
assertEquals(current, bean.getExpectedStart());
assertEquals(2, bean.getSLAConfigMap().size());
assertEquals("END_MISS", bean.getAlertEvents());
assertEquals("alert@example.com", bean.getAlertContact());
}
Aggregations