use of org.jboss.pnc.spi.notifications.MessageCallback in project pnc by project-ncl.
the class DefaultNotifierTest method shouldRemoveAttachedClientWhenItGetsAnException.
@Test
public void shouldRemoveAttachedClientWhenItGetsAnException() throws Exception {
ArgumentCaptor<MessageCallback> messageCallback = ArgumentCaptor.forClass(MessageCallback.class);
// given
Notifier notifier = new DefaultNotifier();
AttachedClient attachedClient = mock(AttachedClient.class);
doReturn(true).when(attachedClient).isEnabled();
notifier.attachClient(attachedClient);
// when
notifier.sendMessage(new Object());
// then
verify(attachedClient).sendMessage(any(), messageCallback.capture());
messageCallback.getValue().failed(attachedClient, new Throwable());
assertThat(notifier.getAttachedClientsCount()).isEqualTo(0);
}
use of org.jboss.pnc.spi.notifications.MessageCallback in project pnc by project-ncl.
the class DefaultNotifierTest method shouldSendAsynchAMessage.
@Test
public void shouldSendAsynchAMessage() throws Exception {
ArgumentCaptor<MessageCallback> messageCallback = ArgumentCaptor.forClass(MessageCallback.class);
// given
Notifier notifier = new DefaultNotifier();
AttachedClient attachedClient = mock(AttachedClient.class);
doReturn(true).when(attachedClient).isEnabled();
notifier.attachClient(attachedClient);
// when
notifier.sendMessage(new Object());
// then
verify(attachedClient).sendMessage(any(), messageCallback.capture());
messageCallback.getValue().successful(attachedClient);
assertThat(notifier.getAttachedClientsCount()).isEqualTo(1);
}
Aggregations