@Test public void testDoGetShouldCallSaveStubConfigurationsWhenAnExceptionOccurred() throws ServletException, IOException, JsonTransformationException { doThrow(new JsonTransformationException("Test", new NullPointerException())).when(stubConfigurationSaverService).saveStubConfigurations(); underTest.doGet(request, response); verify(response).setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { stubConfigurationSaverService.saveStubConfigurations(); logger.info(urlAccessLogMessageAssembler.assembleMessage(req, SUCCESSFUL_ANSWER)); writeResponse(resp, SUCCESSFUL_ANSWER, HttpServletResponse.SC_OK); } catch (Exception e) { logger.info(urlAccessLogMessageAssembler.assembleMessage(req, e.getMessage()), e); writeResponse(resp, "Saving FAILED! " + e.getMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
StubConfigurationSaverServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { stubConfigurationSaverService.saveStubConfigurations(); logger.info(urlAccessLogMessageAssembler.assembleMessage(req, SUCCESSFUL_ANSWER)); writeResponse(resp, SUCCESSFUL_ANSWER, HttpServletResponse.SC_OK); } catch (Exception e) { logger.info(urlAccessLogMessageAssembler.assembleMessage(req, e.getMessage()), e); writeResponse(resp, "Saving FAILED! " + e.getMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } }
StubConfigurationSaverServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { stubConfigurationSaverService.saveStubConfigurations(); logger.info(urlAccessLogMessageAssembler.assembleMessage(req, SUCCESSFUL_ANSWER)); writeResponse(resp, SUCCESSFUL_ANSWER, HttpServletResponse.SC_OK); } catch (Exception e) { logger.info(urlAccessLogMessageAssembler.assembleMessage(req, e.getMessage()), e); writeResponse(resp, "Saving FAILED! " + e.getMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } @Autowired  StubConfigurationSaverServlet(StubConfigurationSaverService stubConfigurationSaverService, UrlAccessLogMessageAssembler urlAccessLogMessageAssembler); }
StubConfigurationSaverServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { stubConfigurationSaverService.saveStubConfigurations(); logger.info(urlAccessLogMessageAssembler.assembleMessage(req, SUCCESSFUL_ANSWER)); writeResponse(resp, SUCCESSFUL_ANSWER, HttpServletResponse.SC_OK); } catch (Exception e) { logger.info(urlAccessLogMessageAssembler.assembleMessage(req, e.getMessage()), e); writeResponse(resp, "Saving FAILED! " + e.getMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } @Autowired  StubConfigurationSaverServlet(StubConfigurationSaverService stubConfigurationSaverService, UrlAccessLogMessageAssembler urlAccessLogMessageAssembler);  }
StubConfigurationSaverServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { stubConfigurationSaverService.saveStubConfigurations(); logger.info(urlAccessLogMessageAssembler.assembleMessage(req, SUCCESSFUL_ANSWER)); writeResponse(resp, SUCCESSFUL_ANSWER, HttpServletResponse.SC_OK); } catch (Exception e) { logger.info(urlAccessLogMessageAssembler.assembleMessage(req, e.getMessage()), e); writeResponse(resp, "Saving FAILED! " + e.getMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } @Autowired  StubConfigurationSaverServlet(StubConfigurationSaverService stubConfigurationSaverService, UrlAccessLogMessageAssembler urlAccessLogMessageAssembler);   }