SequenceHandlingStatusServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); boolean sequenceHandlingUsage = sequenceHandlingToggle.isOn(); out.write("{\"sequenceHandlingUsage\": " + sequenceHandlingUsage + "}"); out.flush(); out.close(); } @Autowired  SequenceHandlingStatusServlet(SequenceHandlingToggle sequenceHandlingToggle);   }
@Test public void testDoGetShouldWriteJsonMessage() throws ServletException, IOException { given(resp.getWriter()).willReturn(printWriter); given(sequenceHandlingToggle.isOn()).willReturn(true); underTest.doGet(req, resp); verify(resp).setContentType("application/json"); verify(printWriter).write("{\"sequenceHandlingUsage\": true}"); verify(printWriter).flush(); verify(printWriter).close(); }