ClientLibrariesImpl implements ClientLibraries { @Override public String getJsAndCssIncludes() { return getLibIncludes(null); }  @NotNull @Override String getJsInline(); @NotNull @Override String getCssInline(); @Override String getJsIncludes(); @Override String getCssIncludes(); @Override String getJsAndCssIncludes(); static final String COMPONENTS_SERVICE; }
@Test void testGetCategoriesWithInjectedCategory() { Map<String,Object> attributes = new HashMap<>(); attributes.put("categories", TEASER_CATEGORY); ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes); StringBuilder includes = new StringBuilder(); includes.append(jsIncludes.get(TEASER_CATEGORY)); includes.append(cssIncludes.get(TEASER_CATEGORY)); assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes()); }
@Test void testGetCategoriesWithInjectedCategories() { Map<String,Object> attributes = new HashMap<>(); attributes.put("categories", TEASER_CATEGORY + "," + ACCORDION_CATEGORY); ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes); StringBuilder includes = new StringBuilder(); includes.append(jsIncludes.get(TEASER_CATEGORY)); includes.append(jsIncludes.get(ACCORDION_CATEGORY)); includes.append(cssIncludes.get(TEASER_CATEGORY)); includes.append(cssIncludes.get(ACCORDION_CATEGORY)); assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes()); }
@Test void testGetCategoriesWithInjectedResourceType() { Map<String,Object> attributes = new HashMap<>(); attributes.put("resourceTypes", new HashSet<String>() {{ add("core/wcm/components/accordion/v1/accordion"); }}); ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes); StringBuilder includes = new StringBuilder(); includes.append(jsIncludes.get(ACCORDION_CATEGORY)); includes.append(cssIncludes.get(ACCORDION_CATEGORY)); assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes()); }
@Test void testGetCategoriesWithInjectedResourceTypesAndInheritance() { Map<String,Object> attributes = new HashMap<>(); attributes.put("resourceTypes", new HashSet<String>() {{ add("core/wcm/components/accordion/v1/accordion"); add("core/wcm/components/carousel/v3/carousel"); }}); ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes); StringBuilder includes = new StringBuilder(); includes.append(jsIncludes.get(ACCORDION_CATEGORY)); includes.append(jsIncludes.get(CAROUSEL_CATEGORY)); includes.append(cssIncludes.get(ACCORDION_CATEGORY)); includes.append(cssIncludes.get(CAROUSEL_CATEGORY)); assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes()); }
@Test void testGetCategoriesWithInjectedResourceTypesAndInheritanceDisabled() { Map<String,Object> attributes = new HashMap<>(); attributes.put("resourceTypes", new HashSet<String>() {{ add("core/wcm/components/accordion/v1/accordion"); add("core/wcm/components/carousel/v3/carousel"); }}); attributes.put("inherited", false); ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes); StringBuilder includes = new StringBuilder(); includes.append(jsIncludes.get(ACCORDION_CATEGORY)); includes.append(cssIncludes.get(ACCORDION_CATEGORY)); assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes()); }
@Test void testGetJsAndCssIncludes() { Map<String,Object> attributes = new HashMap<>(); attributes.put("categories", TEASER_CATEGORY + "," + ACCORDION_CATEGORY + "," + CAROUSEL_CATEGORY); ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes); StringBuilder includes = new StringBuilder(); includes.append(jsIncludes.get(TEASER_CATEGORY)); includes.append(jsIncludes.get(ACCORDION_CATEGORY)); includes.append(jsIncludes.get(CAROUSEL_CATEGORY)); includes.append(cssIncludes.get(TEASER_CATEGORY)); includes.append(cssIncludes.get(ACCORDION_CATEGORY)); includes.append(cssIncludes.get(CAROUSEL_CATEGORY)); assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes()); }
@Test void testGetJsAndCssIncludesWithInjectedAttributes() { Map<String,Object> attributes = new HashMap<>(); attributes.put("categories", TEASER_CATEGORY + "," + ACCORDION_CATEGORY + "," + CAROUSEL_CATEGORY); attributes.put("async", true); attributes.put("defer", true); attributes.put("crossorigin", "anonymous"); attributes.put("onload", "myFunction()"); attributes.put("media", "print"); ClientLibraries clientlibs = getClientLibrariesUnderTest(ROOT_PAGE, attributes); StringBuilder includes = new StringBuilder(); includes.append(jsIncludesWithAttributes.get(TEASER_CATEGORY)); includes.append(jsIncludesWithAttributes.get(ACCORDION_CATEGORY)); includes.append(jsIncludesWithAttributes.get(CAROUSEL_CATEGORY)); includes.append(cssIncludesWithAttributes.get(TEASER_CATEGORY)); includes.append(cssIncludesWithAttributes.get(ACCORDION_CATEGORY)); includes.append(cssIncludesWithAttributes.get(CAROUSEL_CATEGORY)); assertEquals(includes.toString(), clientlibs.getJsAndCssIncludes()); }