@Test public void testDoGetWhenRequestBodyIsEmptyNotShouldCallStubDescriptorConstructor() throws ServletException, IOException { given(request.getContentLength()).willReturn(0); underTest.doGet(request, response); verify(writer).write("Please provide a non-empty stub configuration!"); }
@Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); if (request.getContentLength() > 0) { ServletInputStream inputStream = request.getInputStream(); try { routingService.performModification(new NewStubDescriptorCommand(inputStream, stubDescriptorJsonFactory, sequenceDescriptorHolder)); serviceMap.detectServices(); LOGGER.info(urlAccessLogMessageAssembler.assembleMessage(request, "New stub configuration was uploaded to Wilma.")); } catch (ClassNotFoundException | NoClassDefFoundError | SystemException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Stub config uploading failed: " + e.getMessage()); LOGGER.warn(urlAccessLogMessageAssembler.assembleMessage(request, "Stub config uploading failed: " + e.getMessage()), e); } } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Please provide a non-empty stub configuration!"); } }
ExternalStubConfigUploadServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); if (request.getContentLength() > 0) { ServletInputStream inputStream = request.getInputStream(); try { routingService.performModification(new NewStubDescriptorCommand(inputStream, stubDescriptorJsonFactory, sequenceDescriptorHolder)); serviceMap.detectServices(); LOGGER.info(urlAccessLogMessageAssembler.assembleMessage(request, "New stub configuration was uploaded to Wilma.")); } catch (ClassNotFoundException | NoClassDefFoundError | SystemException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Stub config uploading failed: " + e.getMessage()); LOGGER.warn(urlAccessLogMessageAssembler.assembleMessage(request, "Stub config uploading failed: " + e.getMessage()), e); } } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Please provide a non-empty stub configuration!"); } } }
ExternalStubConfigUploadServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); if (request.getContentLength() > 0) { ServletInputStream inputStream = request.getInputStream(); try { routingService.performModification(new NewStubDescriptorCommand(inputStream, stubDescriptorJsonFactory, sequenceDescriptorHolder)); serviceMap.detectServices(); LOGGER.info(urlAccessLogMessageAssembler.assembleMessage(request, "New stub configuration was uploaded to Wilma.")); } catch (ClassNotFoundException | NoClassDefFoundError | SystemException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Stub config uploading failed: " + e.getMessage()); LOGGER.warn(urlAccessLogMessageAssembler.assembleMessage(request, "Stub config uploading failed: " + e.getMessage()), e); } } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Please provide a non-empty stub configuration!"); } } @Autowired  ExternalStubConfigUploadServlet(UrlAccessLogMessageAssembler urlAccessLogMessageAssembler, StubDescriptorJsonFactory stubDescriptorJsonFactory,
                                           RoutingService routingService, SequenceDescriptorHolder sequenceDescriptorHolder, ServiceMap serviceMap); }
ExternalStubConfigUploadServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); if (request.getContentLength() > 0) { ServletInputStream inputStream = request.getInputStream(); try { routingService.performModification(new NewStubDescriptorCommand(inputStream, stubDescriptorJsonFactory, sequenceDescriptorHolder)); serviceMap.detectServices(); LOGGER.info(urlAccessLogMessageAssembler.assembleMessage(request, "New stub configuration was uploaded to Wilma.")); } catch (ClassNotFoundException | NoClassDefFoundError | SystemException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Stub config uploading failed: " + e.getMessage()); LOGGER.warn(urlAccessLogMessageAssembler.assembleMessage(request, "Stub config uploading failed: " + e.getMessage()), e); } } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Please provide a non-empty stub configuration!"); } } @Autowired  ExternalStubConfigUploadServlet(UrlAccessLogMessageAssembler urlAccessLogMessageAssembler, StubDescriptorJsonFactory stubDescriptorJsonFactory,
                                           RoutingService routingService, SequenceDescriptorHolder sequenceDescriptorHolder, ServiceMap serviceMap);  }
ExternalStubConfigUploadServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); if (request.getContentLength() > 0) { ServletInputStream inputStream = request.getInputStream(); try { routingService.performModification(new NewStubDescriptorCommand(inputStream, stubDescriptorJsonFactory, sequenceDescriptorHolder)); serviceMap.detectServices(); LOGGER.info(urlAccessLogMessageAssembler.assembleMessage(request, "New stub configuration was uploaded to Wilma.")); } catch (ClassNotFoundException | NoClassDefFoundError | SystemException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Stub config uploading failed: " + e.getMessage()); LOGGER.warn(urlAccessLogMessageAssembler.assembleMessage(request, "Stub config uploading failed: " + e.getMessage()), e); } } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); writer.write("Please provide a non-empty stub configuration!"); } } @Autowired  ExternalStubConfigUploadServlet(UrlAccessLogMessageAssembler urlAccessLogMessageAssembler, StubDescriptorJsonFactory stubDescriptorJsonFactory,
                                           RoutingService routingService, SequenceDescriptorHolder sequenceDescriptorHolder, ServiceMap serviceMap);   }