Theme { public void addPlaceHolderValues(RequestLookup requestLookup) { String contextPath = requestLookup.getContextPath(); for (String cssTagSuffix : cssTagSuffixes) { requestLookup.addToPlaceholder(Placeholder.css, "<link href=\"" + contextPath + cssTagSuffix); } for (String headJsTagSuffix : headJsTagSuffixes) { requestLookup.addToPlaceholder(Placeholder.headJs, "<script src=\"" + contextPath + headJsTagSuffix); } for (String bodyJsTagSuffix : bodyJsTagSuffixes) { requestLookup.addToPlaceholder(Placeholder.js, "<script src=\"" + contextPath + bodyJsTagSuffix); } } Theme(String name, List<String> cssRelativePaths, List<String> headJsRelativePaths,
                 List<String> bodyJsRelativePaths, String path); String getName(); String getPath(); void addPlaceHolderValues(RequestLookup requestLookup); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static boolean isValidThemeName(String themeName);  }
@Test public void testRenderTheme() { List<String> cssRelativePaths = ImmutableList.of("css/main-styles.css"); List<String> headJsRelativePaths = ImmutableList.of("js/main-script.css"); List<String> bodyJsRelativePaths = ImmutableList.of("js/last-script.css"); Theme theme = new Theme("theme-name", cssRelativePaths, headJsRelativePaths, bodyJsRelativePaths, null); RequestLookup requestLookup = new RequestLookup("/context-path", null, null); theme.addPlaceHolderValues(requestLookup); Optional<String> css = requestLookup.getPlaceholderContent(Placeholder.css); Assert.assertTrue(css.isPresent()); Assert.assertEquals(css.get(), "<link href=\"/context-path/public/themes/theme-name/" + cssRelativePaths.get(0) + "\" rel=\"stylesheet\" type=\"text/css\" />"); Optional<String> headJs = requestLookup.getPlaceholderContent(Placeholder.headJs); Assert.assertTrue(headJs.isPresent()); Assert.assertEquals(headJs.get(), "<script src=\"/context-path/public/themes/theme-name/" + headJsRelativePaths.get(0) + "\" type=\"text/javascript\"></script>"); Optional<String> js = requestLookup.getPlaceholderContent(Placeholder.js); Assert.assertTrue(js.isPresent()); Assert.assertEquals(js.get(), "<script src=\"/context-path/public/themes/theme-name/" + bodyJsRelativePaths.get(0) + "\" type=\"text/javascript\"></script>"); }