use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ListImplTest method testOrderByModificationDate.
@Test
public void testOrderByModificationDate() throws Exception {
Resource resource = context.currentResource("/content/list/listTypes/staticOrderByModificationDateListType");
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
List list = context.request().adaptTo(List.class);
checkListConsistency(list, new String[] { "Page 2", "Page 1" });
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ListImplTest method testTagsListType.
@Test
public void testTagsListType() throws Exception {
Resource resource = context.currentResource("/content/list/listTypes/tagsListType");
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
List list = context.request().adaptTo(List.class);
assertEquals(1, list.getItems().size());
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method testCheckboxOptionsType.
@Test
public void testCheckboxOptionsType() throws Exception {
Resource optionsRes = context.currentResource(CONTENT_ROOT + "/checkbox");
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();
assertEquals("name1", options.getName());
assertEquals("jcr:title1", options.getTitle());
assertEquals("helpMessage1", options.getHelpMessage());
assertEquals(Type.CHECKBOX, options.getType());
assertNotNull(optionItems);
assertTrue(optionItems.size() == 3);
// test the first option item
OptionItem item = optionItems.get(0);
evaluateOptionItem(item, "t1", "v1", true, true);
item = optionItems.get(1);
evaluateOptionItem(item, "t2", "v2", true, false);
item = optionItems.get(2);
evaluateOptionItem(item, "t3", "v3", false, false);
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method testLocalAsOptionsSource.
@Test
public void testLocalAsOptionsSource() {
Resource optionsRes = context.currentResource(CONTENT_ROOT + "/optionsWithLocalSource");
slingBindings.put(WCMBindings.PROPERTIES, optionsRes.adaptTo(ValueMap.class));
slingBindings.put(RESOURCE_PROPERTY, optionsRes);
Options options = context.request().adaptTo(Options.class);
assertEquals(Type.CHECKBOX, options.getType());
String id = "form-options" + "-" + String.valueOf(Math.abs(optionsRes.getPath().hashCode() - 1));
assertEquals(id, options.getId());
assertEquals("local-name", options.getName());
assertEquals("local-title", options.getTitle());
assertEquals("local-helpMessage", options.getHelpMessage());
List<OptionItem> optionItems = options.getItems();
assertNotNull(optionItems);
assertTrue(optionItems.size() == 2);
evaluateOptionItem(optionItems.get(0), "local-item1-name", "local-item1-value", true, false);
evaluateOptionItem(optionItems.get(1), "local-item2-name", "local-item2-value", false, true);
}
use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ListImplTest method testSearchListType.
@Test
public void testSearchListType() throws Exception {
SearchResult searchResult = mock(SearchResult.class);
Hit hit = mock(Hit.class);
when(mockSimpleSearch.getResult()).thenReturn(searchResult);
when(searchResult.getHits()).thenReturn(Collections.singletonList(hit));
Resource contentResource = context.currentResource("/content/list/pages/page_1/jcr:content");
when(hit.getResource()).thenReturn(contentResource);
Resource resource = context.currentResource("/content/list/listTypes/searchListType");
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
List list = context.request().adaptTo(List.class);
assertEquals(1, list.getItems().size());
}
Aggregations