use of com.adobe.cq.wcm.core.components.models.form.Options in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method testDropDownOptionsType.
@Test
public void testDropDownOptionsType() throws Exception {
Resource optionsRes = context.currentResource(CONTENT_ROOT + "/drop-down");
slingBindings.put(WCMBindings.PROPERTIES, optionsRes.adaptTo(ValueMap.class));
slingBindings.put(RESOURCE_PROPERTY, optionsRes);
Options options = context.request().adaptTo(Options.class);
assertEquals(Type.DROP_DOWN, options.getType());
}
use of com.adobe.cq.wcm.core.components.models.form.Options in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method testOptionsDefaultAttributes.
@Test
public void testOptionsDefaultAttributes() {
Resource optionsRes = context.currentResource(CONTENT_ROOT + "/optionsDefault");
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(null, options.getName());
assertEquals(null, options.getValue());
assertEquals(null, options.getTitle());
assertEquals(null, options.getHelpMessage());
List<OptionItem> optionItems = options.getItems();
assertNotNull(optionItems);
assertTrue(optionItems.size() == 0);
}
use of com.adobe.cq.wcm.core.components.models.form.Options in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class OptionsImplTest method testDatasourceAsOptionsSource.
@Test
public void testDatasourceAsOptionsSource() {
setUpMockRequestDispatcher();
Resource optionsRes = context.currentResource(CONTENT_ROOT + "/optionsWithDatasourceSource");
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), "datasource-item1-name", "datasource-item1-value", true, false);
evaluateOptionItem(optionItems.get(1), "datasource-item2-name", "datasource-item2-value", false, true);
}
Aggregations