AMQPBusPublisher implements EventListener { @Override public void onEvent(Event e) { try { sender.sendTextMessage(e.getTarget(), e.getType(), this.apply(e)); } catch (QpidConnectionException qce) { throw qce; } catch (Exception ex) { throw new RuntimeException("Error sending event to message bus", ex); } } @Inject  AMQPBusPublisher(ObjectMapper omapper, QpidConnection sender); @Override void onEvent(Event e); @Override boolean requiresQpid(); void close(); String apply(Event event);  }
@Test public void onEvent() throws JMSException { PrincipalProvider pp = mock(PrincipalProvider.class); when(pp.get()).thenReturn(TestUtil.createPrincipal("admin", null, null)); EventFactory factory = new EventFactory(pp, mapper); Consumer c = TestUtil.createConsumer(); Event e = factory.consumerCreated(c); publisher.onEvent(e); verify(qpid).sendTextMessage(Mockito.eq(Target.CONSUMER), Mockito.eq(Type.CREATED), Mockito.contains("TestConsumer")); }