@Test
  public void testExceptionHandling() throws Exception {
    List<AlertNoticeEntity> notices = getSingleMockNotice("EMAIL");
    AlertNoticeEntity notice = notices.get(0);

    EasyMock.expect(m_dao.findPendingNotices()).andReturn(notices).once();
    EasyMock.expect(m_dispatchFactory.getDispatcher("EMAIL")).andReturn(null).once();
    EasyMock.expect(m_dao.merge(notice)).andReturn(notice).atLeastOnce();

    EasyMock.replay(m_dao, m_dispatchFactory);

    // "startup" the service so that its initialization is done
    AlertNoticeDispatchService service = m_injector.getInstance(AlertNoticeDispatchService.class);
    service.startUp();

    // service trigger with mock executor that blocks
    service.setExecutor(new MockExecutor());
    // no exceptions should be thrown
    service.runOneIteration();

    EasyMock.verify(m_dao, m_dispatchFactory);
  }
Tests a digest dispatch for email.

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