use of com.day.cq.wcm.api.Template in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class PageImpl method populateClientLibCategories.
private void populateClientLibCategories() {
List<String> categories = new ArrayList<>();
Template template = currentPage.getTemplate();
if (template != null && template.hasStructureSupport()) {
Resource templateResource = template.adaptTo(Resource.class);
if (templateResource != null) {
addDefaultTemplateEditorClientLib(templateResource, categories);
addPolicyClientLibs(categories);
}
}
clientLibCategories = categories.toArray(new String[categories.size()]);
}
use of com.day.cq.wcm.api.Template in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class PageImplTest method getPageUnderTest.
private Page getPageUnderTest(String pagePath, String designPath) {
Resource resource = aemContext.currentResource(pagePath);
com.day.cq.wcm.api.Page page = spy(aemContext.currentPage(pagePath));
SlingBindings slingBindings = (SlingBindings) aemContext.request().getAttribute(SlingBindings.class.getName());
Design design = mock(Design.class);
if (designPath != null) {
when(design.getPath()).thenReturn(designPath);
} else {
when(design.getPath()).thenReturn(Designer.DEFAULT_DESIGN_PATH);
}
Resource templateResource = aemContext.resourceResolver().getResource("/conf/coretest/settings/wcm/templates/product-page");
Template template = mock(Template.class);
when(template.hasStructureSupport()).thenReturn(true);
when(template.adaptTo(Resource.class)).thenReturn(templateResource);
when(page.getTemplate()).thenReturn(template);
ContentPolicyMapping mapping = templateResource.getChild(POLICIES_MAPPING_PATH).adaptTo(ContentPolicyMapping.class);
ContentPolicy contentPolicy = mapping.getPolicy();
Style style;
slingBindings.put(WCMBindings.CURRENT_DESIGN, design);
if (contentPolicy != null) {
Resource contentPolicyResource = aemContext.resourceResolver().getResource(contentPolicy.getPath());
style = new MockStyle(contentPolicyResource, contentPolicyResource.adaptTo(ValueMap.class));
} else {
style = mock(Style.class);
when(style.get(anyString(), Matchers.anyObject())).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[1]);
}
slingBindings.put(WCMBindings.CURRENT_STYLE, style);
slingBindings.put(SlingBindings.RESOLVER, aemContext.request().getResourceResolver());
slingBindings.put(WCMBindings.CURRENT_PAGE, page);
slingBindings.put(WCMBindings.PAGE_MANAGER, aemContext.pageManager());
slingBindings.put(SlingBindings.RESOURCE, resource);
slingBindings.put(WCMBindings.PAGE_PROPERTIES, page.getProperties());
MockSlingHttpServletRequest request = aemContext.request();
request.setContextPath(CONTEXT_PATH);
request.setResource(resource);
return request.adaptTo(Page.class);
}
Aggregations