RestServiceImpl implements RestService { @Override public Response processMessage( final String envelope ) { try { messageProcessor.processMessage( envelope ); return Response.accepted().build(); } catch ( MessageException e ) { LOG.error( "Error in processMessage", e ); return Response.serverError().entity( e.getMessage() ).build(); } } RestServiceImpl( final MessageProcessor messageProcessor ); @Override Response processMessage( final String envelope );  }
@Test public void testProcessMessage() throws Exception { Response response = restService.processMessage( "" ); assertEquals( Response.Status.ACCEPTED.getStatusCode(), response.getStatus() ); }
@Test public void testProcessMessageException() throws Exception { doThrow( new MessageException( "" ) ).when( messageProcessor ).processMessage( anyString() ); Response response = restService.processMessage( "" ); assertEquals( Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus() ); }