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