use of org.apache.sling.models.testmodels.classes.ArrayWrappersModel in project sling by apache.
the class ResourceModelClassesTest method testArrayWrappersModel.
@Test
public void testArrayWrappersModel() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("intArray", new Integer[] { 1, 2, 9, 8 });
map.put("secondIntArray", new int[] { 1, 2, 9, 8 });
ValueMap vm = new ValueMapDecorator(map);
Resource res = mock(Resource.class);
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
ArrayWrappersModel model = factory.getAdapter(res, ArrayWrappersModel.class);
assertNotNull(model);
Integer[] intArray = model.getIntArray();
assertEquals(4, intArray.length);
assertEquals(new Integer(2), intArray[1]);
Integer[] secondIntArray = model.getSecondIntArray();
assertEquals(4, secondIntArray.length);
assertEquals(new Integer(2), secondIntArray[1]);
}
Aggregations