ResponseSenderReceiver implements IMessageReceiver { @Override public void receive(final IMessageProcessor processor) throws MessageReceiveException, AsynchronousOperationException { try { action.execute(processor.getEnvironment()); } catch (ActionExecuteException | InvalidArgumentException e) { throw new MessageReceiveException("Error occurred sending response.", e); } } ResponseSenderReceiver(); @Override void receive(final IMessageProcessor processor);  }
@Test public void Should_sendResponseUsingResponseStrategyFromContext() throws Exception { IMessageReceiver receiver = new ResponseSenderReceiver(); receiver.receive(messageProcessorMock); verify(responseStrategyMock).sendResponse(same(envMock)); }
@Test(expected = MessageReceiveException.class) public void Should_wrapExceptionOccurredSendingResponse() throws Exception { doThrow(ResponseException.class).when(responseStrategyMock).sendResponse(same(envMock)); IMessageReceiver receiver = new ResponseSenderReceiver(); receiver.receive(messageProcessorMock); }