@Test
  public void testFailedDispatch() throws Exception {
    MockEmailDispatcher dispatcher = new MockEmailDispatcher();
    List<AlertNoticeEntity> notices = getSingleMockNotice(dispatcher.getType());
    AlertNoticeEntity notice = notices.get(0);

    // these expectations happen b/c we need to mark the notice as FAILED
    EasyMock.expect(m_dao.findPendingNotices()).andReturn(notices).once();
    EasyMock.expect(m_dao.merge(notice)).andReturn(notice).once();
    EasyMock.expect(m_dao.findNoticeByUuid(ALERT_NOTICE_UUID_1)).andReturn(notice).once();
    EasyMock.expect(m_dao.merge(notice)).andReturn(notice).once();
    EasyMock.expect(m_dispatchFactory.getDispatcher(dispatcher.getType())).andReturn(dispatcher).once();

    EasyMock.replay(m_dao, m_dispatchFactory);

    // do NOT startup the service which will force a template NPE
    AlertNoticeDispatchService service = m_injector.getInstance(AlertNoticeDispatchService.class);

    // service trigger with mock executor that blocks
    service.setExecutor(new MockExecutor());
    service.runOneIteration();

    EasyMock.verify(m_dao, m_dispatchFactory);

    Notification notification = dispatcher.getNotification();
    assertNull(notification);
  }
Tests that a failed dispatch invokes the callback to mark the UUIDs of the
notices as FAILED.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java