DocumentOutputUtil { public static Map<String, Object> generateAdminIframeTemplateContext( String appBaseUrl, String iframeIdToUse, String iframeContextInfo, String queryString) throws IOException { String escapedIframeContext = iframeContextInfo == null ? "null" : iframeContextInfo.replace("\"", "\\\""); String queryStringToUse = ""; if (StringUtils.isNotBlank(queryString)) { queryStringToUse = "?" + StringUtils.removeStart(queryString, "?"); } String iframeSource = appBaseUrl + queryStringToUse; String sparkJs = getSparkJs(); HashMap<String, Object> context = new HashMap<String, Object>(); context.put("sparkJs", sparkJs); context.put("iframeId", iframeIdToUse); context.put("iframeSrc", iframeSource); context.put("escapedIframeContext", escapedIframeContext); return context; }  static void applyCacheKeysToResourceUrls(Document document, long pluginModifiedTimestamp, Locale locale); static String getIframeContentWindowJs(); static String getIframeAdminContentWrapperTemplate(); static Map<String, Object> generateAdminIframeTemplateContext(
            String appBaseUrl, String iframeIdToUse,
            String iframeContextInfo, String queryString);  }
@Test public void generateAdminIframeTemplateContext() throws IOException { Map<String, Object> res = DocumentOutputUtil.generateAdminIframeTemplateContext("/test/base/url/", "iframe-id", "{\"test-key\": \"test-value\"}", ""); Assert.assertEquals("iframe-id", res.get(iframeIdContextKey)); Assert.assertEquals("/test/base/url/", res.get(iframeSrcContextKey)); Assert.assertEquals("", res.get(sparkJsContextKey)); Assert.assertEquals("{\\\"test-key\\\": \\\"test-value\\\"}", res.get(iframeInjContextVelocityKey)); res = DocumentOutputUtil.generateAdminIframeTemplateContext("/test2/", "id_of_second_iframe", "context information string '+!&", "?space=32"); Assert.assertEquals("id_of_second_iframe", res.get(iframeIdContextKey)); Assert.assertEquals("/test2/?space=32", res.get(iframeSrcContextKey)); Assert.assertEquals("", res.get(sparkJsContextKey)); Assert.assertEquals("context information string '+!&", res.get(iframeInjContextVelocityKey)); res = DocumentOutputUtil.generateAdminIframeTemplateContext("/test/3/", "id3", "{'context': {'pages': ['test1', 'test2'], 'result': {'success': false, 'code': 404}}}", "test_value=false&admin=true"); Assert.assertEquals("id3", res.get(iframeIdContextKey)); Assert.assertEquals("/test/3/?test_value=false&admin=true", res.get(iframeSrcContextKey)); Assert.assertEquals("", res.get(sparkJsContextKey)); Assert.assertEquals( "{'context': {'pages': ['test1', 'test2'], 'result': {'success': false, 'code': 404}}}", res.get(iframeInjContextVelocityKey)); }