@Test
public void testAlertsAvailable() throws InterruptedException {

    TestAlert mgrAlert = new TestAlert(this.manager, true);
    TestAlert srcAlert = new TestAlert(this.source);
    CountDownLatch latch = new CountDownLatch(3);
    this.provider.addAlertSource(this.source);
    this.provider.addAlertManager(this.manager);
    when(this.source.getAlerts(any(AlertCriteria.class))).thenAnswer(iteratorAnswer(srcAlert));
    when(this.manager.getAlerts(any(AlertCriteria.class))).thenAnswer(iteratorAnswer(mgrAlert));
    doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            latch.countDown();
            return null;
        }
    }).when(this.listener).alertChange(any(Alert.class));
    doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            latch.countDown();
            return null;
        }
    }).when(this.responder).alertChange(any(Alert.class), any(AlertResponse.class));
    this.provider.alertsAvailable(2);
    latch.await(10, TimeUnit.SECONDS);
    verify(this.listener, times(2)).alertChange(any(Alert.class));
    verify(this.responder, times(1)).alertChange(any(Alert.class), any(AlertResponse.class));
}