Search in sources :

Example 1 with ModifiableValueMapDecorator

use of org.apache.sling.api.wrappers.ModifiableValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.

the class EnsureOakIndexJobHandlerTest method getEnsureOakDefinition.

Resource getEnsureOakDefinition(Map<String, Object> properties) {
    Resource r = mock(Resource.class);
    ValueMap vm = new MockValueMap(r, properties);
    when(r.getValueMap()).thenReturn(vm);
    when(r.adaptTo(ModifiableValueMap.class)).thenReturn(new ModifiableValueMapDecorator(properties));
    when(r.getName()).thenReturn(INDEX_NAME);
    when(r.getPath()).thenReturn(DEFINITION_PATH);
    when(r.listChildren()).thenReturn(IteratorUtils.EMPTY_LIST_ITERATOR);
    return r;
}
Also used : ModifiableValueMapDecorator(org.apache.sling.api.wrappers.ModifiableValueMapDecorator) MockValueMap(org.apache.sling.testing.resourceresolver.MockValueMap) ValueMap(org.apache.sling.api.resource.ValueMap) MockValueMap(org.apache.sling.testing.resourceresolver.MockValueMap) ModifiableValueMap(org.apache.sling.api.resource.ModifiableValueMap) Resource(org.apache.sling.api.resource.Resource)

Example 2 with ModifiableValueMapDecorator

use of org.apache.sling.api.wrappers.ModifiableValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.

the class EnsureOakIndexJobHandlerTest method getOakDefinition.

Resource getOakDefinition(Map<String, Object> properties) {
    Resource r = mock(Resource.class);
    ValueMap vm = new MockValueMap(r, properties);
    when(r.adaptTo(ModifiableValueMap.class)).thenReturn(new ModifiableValueMapDecorator(properties));
    when(r.getValueMap()).thenReturn(vm);
    when(r.getName()).thenReturn(INDEX_NAME);
    when(r.getPath()).thenReturn(OAK_INDEX + "/" + INDEX_NAME);
    when(r.listChildren()).thenReturn(IteratorUtils.EMPTY_LIST_ITERATOR);
    return r;
}
Also used : ModifiableValueMapDecorator(org.apache.sling.api.wrappers.ModifiableValueMapDecorator) MockValueMap(org.apache.sling.testing.resourceresolver.MockValueMap) ValueMap(org.apache.sling.api.resource.ValueMap) MockValueMap(org.apache.sling.testing.resourceresolver.MockValueMap) ModifiableValueMap(org.apache.sling.api.resource.ModifiableValueMap) Resource(org.apache.sling.api.resource.Resource)

Example 3 with ModifiableValueMapDecorator

use of org.apache.sling.api.wrappers.ModifiableValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.

the class ProcessInstanceImpl method init.

@Override
public void init(ResourceResolver resourceResolver, Map<String, Object> parameterMap) throws DeserializeException, RepositoryException {
    ValueMap inputs = new ModifiableValueMapDecorator(parameterMap);
    infoBean.setRequestInputs(inputs);
    definition.parseInputs(inputs);
}
Also used : ModifiableValueMapDecorator(org.apache.sling.api.wrappers.ModifiableValueMapDecorator) ValueMap(org.apache.sling.api.resource.ValueMap) ModifiableValueMap(org.apache.sling.api.resource.ModifiableValueMap)

Example 4 with ModifiableValueMapDecorator

use of org.apache.sling.api.wrappers.ModifiableValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.

the class ChildrenAsPropertyResourceTest method setUp.

@Before
public void setUp() throws Exception {
    valueMap = new ModifiableValueMapDecorator(new HashMap<String, Object>());
    when(resource.getPath()).thenReturn("/content/test");
    when(resource.getValueMap()).thenReturn(valueMap);
    when(resource.adaptTo(ValueMap.class)).thenReturn(valueMap);
    when(resource.adaptTo(ModifiableValueMap.class)).thenReturn(valueMap);
    when(resource.getResourceResolver()).thenReturn(resourceResolver);
    entry1.put("name", "dog");
    entry1.put("sound", "woof");
    entry1.put("jcr:primaryType", "nt:unstructured");
    entry2.put("name", "cat");
    entry2.put("sound", "meow");
    entry1.put("jcr:primaryType", "nt:unstructured");
    entry3.put("name", "fish");
    entry3.put("sound", "...");
    entry1.put("jcr:primaryType", "nt:unstructured");
    entry100.put("name", "dog");
    entry100.put("sound", "woof");
    entry100.put("double", 20.002D);
    entry100.put("long", 2000L);
    entry100.put("bigdecimal", "10000.000001");
    entry100.put("bigdecimal2", "20000.000002");
    entry100.put("integer", 100);
    entry100.put("integerAsLong", 100L);
    entry100.put("integerAsDouble", 100D);
    Calendar cal = Calendar.getInstance();
    cal.set(2001, 1, 1, 1, 1, 1);
    entry100.put("date", cal.getTime());
    entry100.put("calendar", cal);
    entry100.put("boolean", true);
    entry100.put("booleanAsString", "true");
    entry100.put("strArray", new String[] { "one", "two" });
    entry1.put("jcr:primaryType", "nt:unstructured");
    unsortedJSON.put("entry-2", new JSONObject(entry2));
    unsortedJSON.put("entry-1", new JSONObject(entry1));
    unsortedJSON.put("entry-3", new JSONObject(entry3));
    sortedJSON.put("entry-1", new JSONObject(entry1));
    sortedJSON.put("entry-2", new JSONObject(entry2));
    sortedJSON.put("entry-3", new JSONObject(entry3));
}
Also used : ModifiableValueMapDecorator(org.apache.sling.api.wrappers.ModifiableValueMapDecorator) JSONObject(org.apache.sling.commons.json.JSONObject) HashMap(java.util.HashMap) Calendar(java.util.Calendar) Before(org.junit.Before)

Example 5 with ModifiableValueMapDecorator

use of org.apache.sling.api.wrappers.ModifiableValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.

the class AnnotatedFieldDeserializerTest method testBooleanFalseByDefault.

/**
 * Check if booleans are assumed false if missing.
 *
 * @throws java.lang.Exception
 */
@Test
public void testBooleanFalseByDefault() throws Exception {
    System.out.println("processInput");
    PrimitivesTest target = new PrimitivesTest();
    Map<String, Object> params = new HashMap<>();
    params.put("intValue", "123");
    params.put("doubleValue", numberFormat.format(123.456));
    params.put("floatValue", numberFormat.format(234.567f));
    params.put("longValue", "1234567890");
    target.booleanValue = true;
    AnnotatedFieldDeserializer.deserializeFormFields(target, new ModifiableValueMapDecorator(params));
    assertEquals(123, target.intValue);
    assertEquals(123.456D, target.doubleValue, 0);
    assertEquals(234.567F, target.floatValue, 0);
    assertEquals(1234567890L, target.longValue);
    assertEquals(false, target.booleanValue);
}
Also used : ModifiableValueMapDecorator(org.apache.sling.api.wrappers.ModifiableValueMapDecorator) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

ModifiableValueMapDecorator (org.apache.sling.api.wrappers.ModifiableValueMapDecorator)7 HashMap (java.util.HashMap)4 ModifiableValueMap (org.apache.sling.api.resource.ModifiableValueMap)3 ValueMap (org.apache.sling.api.resource.ValueMap)3 Test (org.junit.Test)3 Resource (org.apache.sling.api.resource.Resource)2 MockValueMap (org.apache.sling.testing.resourceresolver.MockValueMap)2 Calendar (java.util.Calendar)1 JSONObject (org.apache.sling.commons.json.JSONObject)1 Before (org.junit.Before)1