use of org.motechproject.event.MotechEvent in project motech by motech.
the class ServerEventRelayTest method createEvent.
private MotechEvent createEvent(String messageDestination) {
MotechEvent event = createEvent();
event.setMessageDestination(messageDestination);
return event;
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class ServerEventRelayTest method testRelayToSingleListenerWithoutMessageDestination.
@Test
public void testRelayToSingleListenerWithoutMessageDestination() throws Exception {
MotechEvent motechEvent = createEvent();
setUpListeners(SUBJECT, eventListener);
eventRelay.relayQueueEvent(motechEvent);
verify(eventListener, never()).handle(motechEvent);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class ServerEventRelayTest method shouldNotifyCallbackServiceOnFailedEventHandling.
@Test
public void shouldNotifyCallbackServiceOnFailedEventHandling() throws Exception {
MotechEvent motechEvent = createEvent(LISTENER_IDENTIFIER);
motechEvent.setCallbackName(TEST_SERVICE_CALLBACK);
setUpListeners(SUBJECT, eventListener);
when(bundleContext.getServiceReferences(EventCallbackService.class, null)).thenReturn(Arrays.asList(serviceReference));
when(bundleContext.getService(serviceReference)).thenReturn(callbackService);
when(callbackService.getName()).thenReturn(TEST_SERVICE_CALLBACK);
RuntimeException initCause = new RuntimeException();
doThrow(new RuntimeException("Failed", initCause)).when(eventListener).handle(any(MotechEvent.class));
eventRelay.relayQueueEvent(motechEvent);
verify(eventListener).handle(motechEvent);
verify(callbackService).failureCallback(motechEvent, initCause);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class ServerEventRelayTest method testRelayToSingleListenerWithMessageDestination.
@Test
public void testRelayToSingleListenerWithMessageDestination() throws Exception {
MotechEvent motechEvent = createEvent(LISTENER_IDENTIFIER);
setUpListeners(SUBJECT, eventListener);
eventRelay.relayQueueEvent(motechEvent);
verify(eventListener).handle(motechEvent);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class ServerEventRelayTest method testThatOnlyListenerIdentifiedByMessageDestinationHandlesEvent.
@Test
public void testThatOnlyListenerIdentifiedByMessageDestinationHandlesEvent() throws Exception {
setUpListeners(SUBJECT, eventListener, secondaryEventListener);
MotechEvent motechEvent = createEvent(LISTENER_IDENTIFIER);
eventRelay.relayQueueEvent(motechEvent);
verify(eventListener).handle(motechEvent);
verify(secondaryEventListener, never()).handle(any(MotechEvent.class));
}
Aggregations