### Question:
EventPublisher { public void publishEvent(final E event) { logger.debug("Publishing: " + event); final TypedMessage typedMessage = new SimpleMessage(event.type(), event.serialize()); messagePublisher.publish(typedMessage); } protected  EventPublisher(final MessagePublisher<TypedMessage> messagePublisher); void publishEvent(final E event);  }### Answer:
@SuppressWarnings("unchecked") @Test public void shouldPublishEvent_withEvent() { final MessagePublisher<TypedMessage> messagePublisher = mock(MessagePublisher.class); final Event event = mock(Event.class); final String type = Randoms.randomString(5); when(event.type()).thenReturn(type); final String serialized = Randoms.randomString(); when(event.serialize()).thenReturn(serialized); final EventPublisher<Event> eventPublisher = new EventPublisher<Event>(messagePublisher) { }; eventPublisher.publishEvent(event); final ArgumentCaptor<TypedMessage> messageArgumentCaptor = ArgumentCaptor.forClass(TypedMessage.class); verify(messagePublisher).publish(messageArgumentCaptor.capture()); assertEquals(type, messageArgumentCaptor.getValue().getType()); assertEquals(serialized, messageArgumentCaptor.getValue().getPayload()); }