use of org.apache.sling.models.testmodels.classes.ListModel in project sling by apache.
the class ResourceModelClassesTest method testListModel.
@Test
public void testListModel() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("intList", new Integer[] { 1, 2, 9, 8 });
map.put("stringList", new String[] { "hello", "world" });
ValueMap vm = new ValueMapDecorator(map);
Resource res = mock(Resource.class);
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
ListModel model = factory.getAdapter(res, ListModel.class);
assertNotNull(model);
assertEquals(4, model.getIntList().size());
assertEquals(new Integer(2), model.getIntList().get(1));
assertEquals(2, model.getStringList().size());
assertEquals("hello", model.getStringList().get(0));
}
Aggregations