ActivationListener implements EventListener { @Override public void onEvent(Event e) { if (e.getType().equals(Event.Type.CREATED) && e.getTarget().equals(Event.Target.POOL)) { try { String subscriptionId = mapper.readTree(e.getEventData()).get("subscriptionId").asText(); subscriptionService.sendActivationEmail(subscriptionId); } catch (JsonMappingException ex) { logError(e); } catch (JsonParseException ex) { logError(e); } catch (IOException ex) { logError(e); } } } @Inject  ActivationListener(SubscriptionServiceAdapter subService,
        @Named("ActivationListenerObjectMapper") ObjectMapper objectMapper); @Override void onEvent(Event e); @Override boolean requiresQpid();  }
@Test public void testActivationEmailIsSentWithCorrectSubscriptionId() { Event event = mock(Event.class); when(event.getTarget()).thenReturn(Event.Target.POOL); when(event.getType()).thenReturn(Event.Type.CREATED); when(event.getEventData()).thenReturn("{\"subscriptionId\":\"sub-id-1\"}"); listener.onEvent(event); verify(subscriptionService, times(1)).sendActivationEmail("sub-id-1"); }