@Test public void testDoGetWhenTypeIsTemplateShouldWriteResourceToResponse() throws ServletException, IOException { String expectedResult = "{\"files\":[\"template.xml\"]}"; given(request.getParameter(TYPE_PARAMETER)).willReturn(TEMPLATE); given(stubResourcePathProvider.getTemplatesPath()).willReturn(path); given(path.toFile()).willReturn(file); given(fileListJsonBuilder.buildFileListJson(file)).willReturn(expectedResult); underTest.doGet(request, response); verify(writer).write(expectedResult); }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String type = req.getParameter("type"); if (type != null) { Path path = getResourcePath(type); if (path != null) { writeResponse(req, resp, path); } else { writeError(resp, String.format(ERROR_MESSAGE_TEMPLATE, type, INTERCEPTOR, CONDITION_CHECKER, RESPONSE_FORMATTER, TEMPLATE, JAR, SEQUENCE_HANDLER)); } } else { writeError(resp, NO_TYPE_ERR_MSG); } }
StubResourceHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String type = req.getParameter("type"); if (type != null) { Path path = getResourcePath(type); if (path != null) { writeResponse(req, resp, path); } else { writeError(resp, String.format(ERROR_MESSAGE_TEMPLATE, type, INTERCEPTOR, CONDITION_CHECKER, RESPONSE_FORMATTER, TEMPLATE, JAR, SEQUENCE_HANDLER)); } } else { writeError(resp, NO_TYPE_ERR_MSG); } } }
StubResourceHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String type = req.getParameter("type"); if (type != null) { Path path = getResourcePath(type); if (path != null) { writeResponse(req, resp, path); } else { writeError(resp, String.format(ERROR_MESSAGE_TEMPLATE, type, INTERCEPTOR, CONDITION_CHECKER, RESPONSE_FORMATTER, TEMPLATE, JAR, SEQUENCE_HANDLER)); } } else { writeError(resp, NO_TYPE_ERR_MSG); } } @Autowired  StubResourceHandlerServlet(FileListJsonBuilder fileListJsonBuilder, StubResourcePathProvider stubResourcePathProvider, ResourceFileNameHandler resourceFileNameHandler); }
StubResourceHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String type = req.getParameter("type"); if (type != null) { Path path = getResourcePath(type); if (path != null) { writeResponse(req, resp, path); } else { writeError(resp, String.format(ERROR_MESSAGE_TEMPLATE, type, INTERCEPTOR, CONDITION_CHECKER, RESPONSE_FORMATTER, TEMPLATE, JAR, SEQUENCE_HANDLER)); } } else { writeError(resp, NO_TYPE_ERR_MSG); } } @Autowired  StubResourceHandlerServlet(FileListJsonBuilder fileListJsonBuilder, StubResourcePathProvider stubResourcePathProvider, ResourceFileNameHandler resourceFileNameHandler);  }
StubResourceHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String type = req.getParameter("type"); if (type != null) { Path path = getResourcePath(type); if (path != null) { writeResponse(req, resp, path); } else { writeError(resp, String.format(ERROR_MESSAGE_TEMPLATE, type, INTERCEPTOR, CONDITION_CHECKER, RESPONSE_FORMATTER, TEMPLATE, JAR, SEQUENCE_HANDLER)); } } else { writeError(resp, NO_TYPE_ERR_MSG); } } @Autowired  StubResourceHandlerServlet(FileListJsonBuilder fileListJsonBuilder, StubResourcePathProvider stubResourcePathProvider, ResourceFileNameHandler resourceFileNameHandler);   }