### Question:
ApacheRewriteMapServlet extends SlingAllMethodsServlet { @Override protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws IOException { final Resource resource = request.getResource(); final List<SiteMapEntry> entries = structure.get(resource); if (isNull(entries)) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } response.setContentType(TEXT_MIME_TYPE); response.setCharacterEncoding(UTF_8); writeRewriteMap(entries, response.getWriter()); }    }### Answer:
@Test public void noEntries() throws IOException { when(structure.get(resource)).thenReturn(null); model.doGet(request, response); assertEquals(HttpServletResponse.SC_NOT_FOUND, status); assertTrue(StringUtils.isBlank(writer.toString())); }
@Test public void doGet() throws IOException { final List<SiteMapEntry> entries = new LinkedList<>(); SiteMapEntry entry = new SiteMapEntry("/content/page-1"); entry.setUrl("http: entries.add(entry); entry = new SiteMapEntry("/content/page-2"); entry.setUrl("/page-2.html"); entries.add(entry); when(structure.get(resource)).thenReturn(entries); model.doGet(request, response); assertNotEquals(HttpServletResponse.SC_NOT_FOUND, status); assertEquals( StringUtils.strip("/page-1.html /content/page-1.html\n" + "/page-2.html /content/page-2.html"), StringUtils.strip(writer.toString()) ); }