MaintainerPropertiesServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType(APPLICATION_JSON); PrintWriter out = resp.getWriter(); PropertyDTO properties = webAppConfigurationAccess.getProperties(); MaintainerProperties maintainerProperties = properties.getMaintainerProperties(); out.write(maintainerPropertiesJsonBuilder.buildMaintainerPropertiesJson(maintainerProperties)); out.flush(); out.close(); } @Autowired  MaintainerPropertiesServlet(MaintainerPropertiesJsonBuilder maintainerPropertiesJsonBuilder, WebAppConfigurationAccess webAppConfigurationAccess);   }
@Test public final void testDoGetShouldCallJsonBuilderAndWriteResponse() throws IOException, ServletException { given(properties.getMaintainerProperties()).willReturn(maintainerProperties); given(response.getWriter()).willReturn(printWriter); given(maintainerPropertiesJsonBuilder.buildMaintainerPropertiesJson(maintainerProperties)).willReturn("json"); underTest.doGet(request, response); verify(response).setContentType("application/json"); verify(printWriter).write("json"); verify(printWriter).flush(); verify(printWriter).close(); }