### Question:
MessagePublisherImpl implements MessagePublisher<T> { @Override public void publish(final T message) throws MessagePublishException { exchange.route(message); } MessagePublisherImpl(final Exchange<T> exchange); @Override void publish(final T message);  }### Answer:
@Test public void shouldPublish_withMessage() { messagePublisherImpl.publish(mockMessage); verify(mockExchange).route(mockMessage); }
@Test public void shouldThrowMessagePublishException_onExceptionFromRoute() { final MessagePublishException mockMessagePublishException = mock(MessagePublishException.class); doThrow(mockMessagePublishException).when(mockExchange).route(any(Message.class)); MessagePublishException thrownException = null; try { messagePublisherImpl.publish(mockMessage); } catch (final MessagePublishException e) { thrownException = e; } assertSame(mockMessagePublishException, thrownException); }