use of org.apache.sling.api.wrappers.ModifiableValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.
the class AnnotatedFieldDeserializerTest method testPrimitiveInputs.
/**
* Check if primitives are deserialized properly.
*
* @throws java.lang.Exception
*/
@Test
public void testPrimitiveInputs() 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");
params.put("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(true, target.booleanValue);
}
use of org.apache.sling.api.wrappers.ModifiableValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.
the class AnnotatedFieldDeserializerTest method testPrimitiveArrayInputs.
/**
* Check if primitives are deserialized properly.
*
* @throws java.lang.Exception
*/
@Test
public void testPrimitiveArrayInputs() throws Exception {
System.out.println("processInput");
PrimitiveArrayTest target = new PrimitiveArrayTest();
Map<String, Object> params = new HashMap<>();
params.put("intValue", new String[] { "123", "456", "789" });
params.put("doubleValue", numberFormat.format(123.456));
params.put("floatValue", new String[] { numberFormat.format(234.567f), numberFormat.format(111.222f), numberFormat.format(333.444f), numberFormat.format(555.666f) });
AnnotatedFieldDeserializer.deserializeFormFields(target, new ModifiableValueMapDecorator(params));
assertArrayEquals(new int[] { 123, 456, 789 }, target.intValue);
assertArrayEquals(new double[] { 123.456D }, target.doubleValue, 0);
assertNotNull(target.floatValue);
assertEquals(4, target.floatValue.size());
assertEquals(234.567F, target.floatValue.get(0), 0);
assertEquals(111.222F, target.floatValue.get(1), 0);
assertEquals(333.444F, target.floatValue.get(2), 0);
assertEquals(555.666F, target.floatValue.get(3), 0);
}
Aggregations