### Question:
QrCodeServlet extends SlingSafeMethodsServlet { @Override protected final void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); if (externalizer == null) { log.warn("Externalizer is not configured. This is required for QR Code servlet to work."); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } else if (request.getResource().getValueMap().get(PN_ENABLED, false)) { final JsonObject json = new JsonObject(); final String publishUrl = externalizer.publishLink(request.getResourceResolver(), request.getRequestPathInfo().getSuffix()); log.debug("Externalized path [ {} ] for QR Code generation to [ {} ]", request.getRequestPathInfo().getSuffix(), publishUrl); if (StringUtils.isNotBlank(publishUrl)) { json.addProperty(JSON_KEY_ENABLED, true); json.addProperty(JSON_KEY_PUBLISH_URL, publishUrl); Gson gson = new Gson(); gson.toJson(json, response.getWriter()); response.getWriter().flush(); } else { log.warn("Externalizer configuration for AEM Publish did not yield a valid URL"); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } else { log.warn("Externalizer configuration for AEM Publish did not yield a valid URL"); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }    }### Answer:
@Test public void doGet() throws Exception { request.setResource(requestResource); when(externalizer.publishLink(request.getResourceResolver(), "/content/externalize-me.html")).thenReturn("http: MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo(); requestPathInfo.setSuffix("/content/externalize-me.html"); qrCodeServlet.doGet(request, response); JSONObject actual = new JSONObject(response.getOutputAsString()); assertEquals(HttpServletResponse.SC_OK, response.getStatus()); assertEquals(true, actual.getBoolean("enabled")); assertEquals("http: }