OperationModeStatusServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); boolean proxyModeOn = proxyModeToggle.isProxyModeOn(); boolean stubModeOn = routingService.isStubModeOn(); boolean wilmaModeOn = !proxyModeOn && !stubModeOn; out.write("{\"proxyMode\":" + proxyModeOn + ",\"stubMode\":" + stubModeOn + ",\"wilmaMode\":" + wilmaModeOn + "}"); out.flush(); out.close(); } @Autowired  OperationModeStatusServlet(ProxyModeToggle proxyModeToggle, RoutingService routingService);   }
@Test public void testDoGetShouldWriteStatusToResponse() throws ServletException, IOException { given(proxyModeToggle.isProxyModeOn()).willReturn(true); given(routingService.isStubModeOn()).willReturn(false); underTest.doGet(request, response); verify(printWriter).write("{\"proxyMode\":true,\"stubMode\":false,\"wilmaMode\":false}"); }
@Test public void testDoGetShouldWriteSetContentTypeToJson() throws ServletException, IOException { given(proxyModeToggle.isProxyModeOn()).willReturn(true); given(routingService.isStubModeOn()).willReturn(false); underTest.doGet(request, response); verify(response).setContentType("application/json"); }