use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method testMulitDropDownOptionsType.
@Test
public void testMulitDropDownOptionsType() throws Exception {
Resource optionsRes = context.currentResource(CONTENT_ROOT + "/multi-drop-down");
slingBindings.put(WCMBindings.PROPERTIES, optionsRes.adaptTo(ValueMap.class));
slingBindings.put(RESOURCE_PROPERTY, optionsRes);
Options options = context.request().adaptTo(Options.class);
assertEquals(Type.MULTI_DROP_DOWN, options.getType());
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method testListAsOptionsSource.
@Test
public void testListAsOptionsSource() {
Resource optionsRes = context.currentResource(CONTENT_ROOT + "/optionsWithListSource");
slingBindings.put(WCMBindings.PROPERTIES, optionsRes.adaptTo(ValueMap.class));
slingBindings.put(RESOURCE_PROPERTY, optionsRes);
Options options = context.request().adaptTo(Options.class);
List<OptionItem> optionItems = options.getItems();
assertNotNull(optionItems);
assertTrue(optionItems.size() == 2);
evaluateOptionItem(optionItems.get(0), "list-item1-name", "list-item1-value", true, false);
evaluateOptionItem(optionItems.get(1), "list-item2-name", "list-item2-value", false, true);
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method setUpMockDataSource.
private void setUpMockDataSource() {
Resource dataSourceResource = context.resourceResolver().getResource(CONTENT_ROOT + "/dataDatasource/datasource/items");
SimpleDataSource dataSource = new SimpleDataSource(dataSourceResource.listChildren());
context.request().setAttribute(DataSource.class.getName(), dataSource);
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class BreadcrumbImplTest method testGetHideCurrent.
@Test
public void testGetHideCurrent() throws Exception {
Resource resource = context.currentResource(CURRENT_PAGE + "/jcr:content/header/breadcrumb-hide-current");
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
underTest = context.request().adaptTo(Breadcrumb.class);
checkBreadcrumbConsistency(new String[] { "Women" });
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class BreadcrumbImplTest method testStyleBasedBreadcrumb.
@Test
public void testStyleBasedBreadcrumb() throws Exception {
Resource resource = context.currentResource(CURRENT_PAGE + "/jcr:content/header/breadcrumb-style-based");
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
Style style = mock(Style.class);
when(style.get(BreadcrumbImpl.PN_START_LEVEL, BreadcrumbImpl.PROP_START_LEVEL_DEFAULT)).thenReturn(3);
when(style.get(BreadcrumbImpl.PN_HIDE_CURRENT, BreadcrumbImpl.PROP_SHOW_HIDDEN_DEFAULT)).thenReturn(false);
when(style.get(BreadcrumbImpl.PN_SHOW_HIDDEN, BreadcrumbImpl.PROP_SHOW_HIDDEN_DEFAULT)).thenReturn(false);
slingBindings.put(WCMBindings.CURRENT_STYLE, style);
underTest = context.request().adaptTo(Breadcrumb.class);
checkBreadcrumbConsistency(new String[] { "Devi Sleeveless Shirt" });
}
Aggregations