use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class AbstractContentLoaderJsonTest method testContentProperties.
@Test
public void testContentProperties() {
Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content/header");
ValueMap props = ResourceUtil.getValueMap(resource);
assertEquals("/content/dam/sample/header.png", props.get("imageReference", String.class));
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class SlingCrudResourceResolverTest method testStringToCalendarConversion.
@Test
public void testStringToCalendarConversion() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
ModifiableValueMap modProps = resource1.adaptTo(ModifiableValueMap.class);
modProps.put("dateISO8601String", ISO8601.format(CALENDAR_VALUE));
resourceResolver.commit();
resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
assertEquals(CALENDAR_VALUE.getTime(), props.get("calendarProp", Calendar.class).getTime());
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class SlingCrudResourceResolverTest method testSimpleProperties_DeepPathAccess.
@Test
public void testSimpleProperties_DeepPathAccess() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath());
assertNotNull(resource1);
assertEquals(testRoot.getName(), resource1.getName());
ValueMap props = ResourceUtil.getValueMap(resource1);
assertEquals(STRING_VALUE, props.get("node1/stringProp", String.class));
assertArrayEquals(STRING_ARRAY_VALUE, props.get("node1/stringArrayProp", String[].class));
assertEquals((Integer) INTEGER_VALUE, props.get("node1/integerProp", Integer.class));
assertEquals((Long) LONG_VALUE, props.get("node1/longProp", Long.class));
assertEquals(DOUBLE_VALUE, props.get("node1/doubleProp", Double.class), 0.0001);
assertEquals(BIGDECIMAL_VALUE, props.get("node1/bigDecimalProp", BigDecimal.class));
assertEquals(BOOLEAN_VALUE, props.get("node1/booleanProp", Boolean.class));
assertEquals(STRING_VALUE, props.get("node1/node11/stringProp11", String.class));
assertTrue(STRING_VALUE, props.containsKey("node1/stringProp"));
assertFalse(STRING_VALUE, props.containsKey("node1/unknownProp"));
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class SlingCrudResourceResolverTest method testDateProperty.
@Test
public void testDateProperty() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class SlingCrudResourceResolverTest method testDatePropertyToCalendar.
@Test
public void testDatePropertyToCalendar() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
Calendar calendarValue = props.get("dateProp", Calendar.class);
assertNotNull(calendarValue);
assertEquals(DATE_VALUE, calendarValue.getTime());
}
Aggregations