### Question:
ModelAsJsonRequestHandler extends RequestHandlerSupport { @Override public void handle(final HttpServletRequest request, final HttpServletResponse response) throws IOException { ResponseHeadersConfigurer.noCache().setHeaders(response); response.setContentType(CONTENT_TYPE); response.setStatus(HttpServletResponse.SC_OK); newGson(request).toJson(modelFactory.create(), response.getWriter()); response.getWriter().flush(); }  @Override void handle(final HttpServletRequest request, final HttpServletResponse response); @Override boolean accept(final HttpServletRequest request); @Override boolean isEnabled(); static final String ENDPOINT_URI; static final String ALIAS; }### Answer:
@Test public void shouldGenerateModelAsJson() throws Exception { victim.handle(mockRequest, mockResponse); assertEquals(readJsonFile("wroModel_simple.json"), outputStream.toString()); }
@Test public void shouldSetCorrectContentType() throws IOException, ServletException { when(mockRequest.getRequestURI()).thenReturn("wroAPI/model"); victim.handle(mockRequest, mockResponse); verify(mockResponse, times(1)).setContentType("application/json"); verify(mockResponse, times(1)).setStatus(HttpServletResponse.SC_OK); }
@Test public void shouldNotProvideProxyUriForExternalResources() throws IOException { when(mockModelFactory.create()).thenReturn(createWroModelExternalModelStub()); final WroManagerFactory managerFactory = new BaseWroManagerFactory().setModelFactory(mockModelFactory); victim = new ModelAsJsonRequestHandler(); final Injector injector = InjectorBuilder.create(managerFactory).build(); injector.inject(victim); victim.handle(mockRequest, mockResponse); assertEquals(readJsonFile("wroModel_external.json"), outputStream.toString()); }