### Question:
SiteMapServlet extends SlingAllMethodsServlet { @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException { final Resource resource = request.getResource(); final int index = urlBuilder.getIndex(request); final String string = index >= 0 ? cache.get(resource, index) : null; if (isBlank(string)) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } response.setContentType(PerConstants.XML_MIME_TYPE); response.setCharacterEncoding(PerConstants.UTF_8); response.getWriter().write(string); }    }### Answer:
@Test public void incorrectIndex() throws IOException { when(urlBuilder.getIndex(request)).thenReturn(-1); model.doGet(request, response); assertEquals(HttpServletResponse.SC_NOT_FOUND, status); assertTrue(StringUtils.isBlank(writer.toString())); }
@Test public void doGet() throws IOException { when(urlBuilder.getIndex(request)).thenReturn(0); when(cache.get(resource, 0)).thenReturn(RESULT); model.doGet(request, response); assertNotEquals(HttpServletResponse.SC_NOT_FOUND, status); assertEquals(RESULT, writer.toString()); }