AMQPBusPublisher implements EventListener { public String apply(Event event) throws JsonProcessingException { return mapper.writeValueAsString(event); } @Inject  AMQPBusPublisher(ObjectMapper omapper, QpidConnection sender); @Override void onEvent(Event e); @Override boolean requiresQpid(); void close(); String apply(Event event);  }
@Test public void testApply() throws IOException { PrincipalProvider pp = mock(PrincipalProvider.class); when(pp.get()).thenReturn(TestUtil.createPrincipal("admin", null, null)); EventFactory factory = new EventFactory(pp, new ObjectMapper()); Consumer c = TestUtil.createConsumer(); Event e = factory.consumerCreated(c); String value = publisher.apply(e); Event e1 = mapper.readValue(value, Event.class); assertEquals(e.getType(), e1.getType()); assertEquals(e.getTarget(), e1.getTarget()); }