@Test
  public void testSingleSnmpDispatch() throws Exception {
    MockSnmpDispatcher dispatcher = new MockSnmpDispatcher();

    List<AlertNoticeEntity> notices = getSnmpMockNotices("SNMP");
    AlertNoticeEntity notice1 = notices.get(0);
    AlertNoticeEntity notice2 = notices.get(1);

    EasyMock.expect(m_dao.findPendingNotices()).andReturn(notices).once();
    EasyMock.expect(m_dao.merge(notice1)).andReturn(notice1).once();
    EasyMock.expect(m_dao.merge(notice2)).andReturn(notice2).once();
    EasyMock.expect(m_dispatchFactory.getDispatcher("SNMP")).andReturn(dispatcher).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());
    service.runOneIteration();

    EasyMock.verify(m_dao, m_dispatchFactory);

    List<Notification> notifications = dispatcher.getNotifications();
    assertEquals(2, notifications.size());
  }
Tests a digest dispatch for SNMP.

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