Search in sources :

Example 6 with MotechListenerEventProxy

use of org.motechproject.event.listener.annotations.MotechListenerEventProxy in project motech by motech.

the class TaskTriggerHandlerTest method shouldRegisterRetryHandlerForSubject.

@Test
public void shouldRegisterRetryHandlerForSubject() {
    String subject = "org.motechproject.messagecampaign.campaign-completed";
    handler.registerHandlerFor(subject, true);
    ArgumentCaptor<EventListener> captor = ArgumentCaptor.forClass(EventListener.class);
    verify(registryService).registerListener(captor.capture(), eq(subject));
    MotechListenerEventProxy proxy = (MotechListenerEventProxy) captor.getValue();
    assertEquals("taskTriggerHandler", proxy.getIdentifier());
    assertEquals(handler, proxy.getBean());
    assertEquals(findMethod(getTargetClass(handler), "handleRetry", MotechEvent.class), proxy.getMethod());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) EventListener(org.motechproject.event.listener.EventListener) MotechListenerEventProxy(org.motechproject.event.listener.annotations.MotechListenerEventProxy) MotechEvent(org.motechproject.event.MotechEvent) Test(org.junit.Test)

Example 7 with MotechListenerEventProxy

use of org.motechproject.event.listener.annotations.MotechListenerEventProxy in project motech by motech.

the class TaskTriggerHandlerTest method shouldRegisterHandlerForSubject.

@Test
public void shouldRegisterHandlerForSubject() {
    String subject = "org.motechproject.messagecampaign.campaign-completed";
    handler.registerHandlerFor(subject);
    ArgumentCaptor<EventListener> captor = ArgumentCaptor.forClass(EventListener.class);
    verify(registryService).registerListener(captor.capture(), eq(subject));
    MotechListenerEventProxy proxy = (MotechListenerEventProxy) captor.getValue();
    assertEquals("taskTriggerHandler", proxy.getIdentifier());
    assertEquals(handler, proxy.getBean());
    assertEquals(findMethod(getTargetClass(handler), "handle", MotechEvent.class), proxy.getMethod());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) EventListener(org.motechproject.event.listener.EventListener) MotechListenerEventProxy(org.motechproject.event.listener.annotations.MotechListenerEventProxy) MotechEvent(org.motechproject.event.MotechEvent) Test(org.junit.Test)

Aggregations

MotechListenerEventProxy (org.motechproject.event.listener.annotations.MotechListenerEventProxy)7 Test (org.junit.Test)5 EventListener (org.motechproject.event.listener.EventListener)4 Method (java.lang.reflect.Method)3 Matchers.anyString (org.mockito.Matchers.anyString)3 MotechListenerAbstractProxy (org.motechproject.event.listener.annotations.MotechListenerAbstractProxy)3 MotechListenerNamedParametersProxy (org.motechproject.event.listener.annotations.MotechListenerNamedParametersProxy)3 ArrayList (java.util.ArrayList)2 MotechEvent (org.motechproject.event.MotechEvent)2 HashSet (java.util.HashSet)1 MotechListener (org.motechproject.event.listener.annotations.MotechListener)1 ReflectionUtils.findMethod (org.springframework.util.ReflectionUtils.findMethod)1