Search in sources :

Example 6 with Options

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());
}
Also used : Options(com.adobe.cq.wcm.core.components.models.form.Options) RequestDispatcherOptions(org.apache.sling.api.request.RequestDispatcherOptions) ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Example 7 with Options

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);
}
Also used : Options(com.adobe.cq.wcm.core.components.models.form.Options) RequestDispatcherOptions(org.apache.sling.api.request.RequestDispatcherOptions) OptionItem(com.adobe.cq.wcm.core.components.models.form.OptionItem) ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Example 8 with Options

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);
}
Also used : Options(com.adobe.cq.wcm.core.components.models.form.Options) RequestDispatcherOptions(org.apache.sling.api.request.RequestDispatcherOptions) OptionItem(com.adobe.cq.wcm.core.components.models.form.OptionItem) ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Aggregations

Options (com.adobe.cq.wcm.core.components.models.form.Options)8 RequestDispatcherOptions (org.apache.sling.api.request.RequestDispatcherOptions)8 Resource (org.apache.sling.api.resource.Resource)8 ValueMap (org.apache.sling.api.resource.ValueMap)8 Test (org.junit.Test)8 OptionItem (com.adobe.cq.wcm.core.components.models.form.OptionItem)5