StubConfigurationOrderServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { String groupName = request.getParameter("groupname"); String tempDir = request.getParameter("direction"); try { int direction = Integer.parseInt(tempDir); stubConfigurationOrderService.doChange(direction, groupName, request); } catch (ClassNotFoundException|NumberFormatException e) { logger.debug(ERROR_MSG, e); writeErrorToResponse(response); } } @Autowired  StubConfigurationOrderServlet(StubConfigurationOrderService stubConfigurationOrderService);   }
@Test public void testDoGetShouldCallDoChangeOfStubConfigurationService() throws ServletException, IOException, ClassNotFoundException { underTest.doGet(request, response); verify(stubConfigurationOrderService).doChange(1, DEFAULT_GROUPNAME, request); }
@Test public void testDoGetShouldCallWriteErrorToResponseBecauseOfWrongParameterFormat() throws ServletException, IOException { given(request.getParameter(PARAMETER_CONSTANS_DIRECTION)).willReturn("dawdaw"); given(response.getWriter()).willReturn(writer); underTest.doGet(request, response); verify(response).setStatus(HttpServletResponse.SC_NOT_FOUND); verify(response).getWriter(); }