StubConfigurationStatusServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { String groupName = request.getParameter("groupname"); String enabledDisabled = request.getParameter("nextstatus"); if ("TRUE".equalsIgnoreCase(enabledDisabled) || "FALSE".equalsIgnoreCase(enabledDisabled)) { boolean nextStatus = Boolean.parseBoolean(enabledDisabled); try { stubConfigurationStatusService.changeStatus(nextStatus, groupName, request); } catch (ClassNotFoundException e) { throw new IOException(e); } } else { writeErrorToResponse(response); } } @Autowired  StubConfigurationStatusServlet(StubConfigurationStatusService stubConfigurationStatusService);   }
@Test public void testDoGetShouldCallDoChangeOfStubConfigurationService() throws ServletException, IOException, ClassNotFoundException { underTest.doGet(request, response); verify(stubConfigurationStatusService).changeStatus(true, DEFAULT_GROUPNAME, request); }
@Test public void testDoGetShouldCallWriteErrorToResponseBecauseOfWrongParameter() throws ServletException, IOException { given(request.getParameter(PARAMETER_CONTANS_NEXTSTATUS)).willReturn("falseaaa"); given(response.getWriter()).willReturn(writer); underTest.doGet(request, response); verify(response).setStatus(HttpServletResponse.SC_NOT_FOUND); verify(response).getWriter(); }