### Question:
TemplateUtils { public static String injectTemplate(final String templateName, final Map<String, Object> data, final Class<?> clazz) { final InputStream stream = clazz.getClassLoader().getResourceAsStream(templateName); if (stream == null) { return null; } try { final String content = GlobalUtils.readStreamAsText(stream); return replaceTemplateData(content, data); } catch (Exception e) { log.error("Error processing template", e); } finally { IOUtils.closeQuietly(stream); } return null; } private  TemplateUtils(); static List<PropertyWrapper> parseBeanProperties(final Path beanPath); static String replaceStringPlaceholders(final String content, final Map<String, String> data); static String replaceTemplateData(final String content, final Map<String, Object> data); static String injectTemplate(final String templateName, final Map<String, Object> data, final Class<?> clazz);  }### Answer:
@Test public void testWhitespaceNewlines() throws Exception { String result = TemplateUtils.injectTemplate("test_java_parsing.txt", getContext().getPlaceholderData(), getClass()); final Object beansPackage = getContext().getPlaceholderData().get("beansPackage"); assertTrue(result.contains((CharSequence) beansPackage)); log.info("{}", result); }
@Test public void testJavaParsing() throws Exception { String result = TemplateUtils.injectTemplate("test_java_parsing.txt", getContext().getPlaceholderData(), getClass()); final Object beansPackage = getContext().getPlaceholderData().get("beansPackage"); assertTrue(result.contains((CharSequence) beansPackage)); log.info("{}", result); }
@Test public void testInjectTemplate() throws Exception { final Map<String, Object> data = new HashMap<>(); data.put("beanReference", BEAN_REF); final Collection<TemplateObject> listObject = new ArrayList<>(); listObject.add(new TemplateObject("repeatable item")); data.put("repeatable", listObject); String result = TemplateUtils.injectTemplate("test_template.ftl", data, getClass()); log.info("result {}", result); assertTrue("Expected " + BEAN_REF, result.contains(BEAN_REF)); assertTrue(result.contains("repeatable item")); }