Search in sources :

Example 1 with DefaultWrappersModel

use of org.apache.sling.models.testmodels.classes.DefaultWrappersModel in project sling by apache.

the class DefaultTest method testDefaultWrappersField.

@Test
public void testDefaultWrappersField() {
    ValueMap vm = new ValueMapDecorator(Collections.<String, Object>emptyMap());
    Resource res = mock(Resource.class);
    when(res.adaptTo(ValueMap.class)).thenReturn(vm);
    DefaultWrappersModel model = factory.getAdapter(res, DefaultWrappersModel.class);
    assertNotNull(model);
    assertEquals(Boolean.valueOf(true), model.getBooleanWrapperProperty());
    // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays, https://github.com/junit-team/junit/issues/86!
    assertTrue(Arrays.equals(new Boolean[] { Boolean.TRUE, Boolean.TRUE }, model.getBooleanWrapperArrayProperty()));
    assertEquals(Long.valueOf(1L), model.getLongWrapperProperty());
    assertArrayEquals(new Long[] { Long.valueOf(1L), Long.valueOf(1L) }, model.getLongWrapperArrayProperty());
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) ValueMapDecorator(org.apache.sling.api.wrappers.ValueMapDecorator) Resource(org.apache.sling.api.resource.Resource) DefaultWrappersModel(org.apache.sling.models.testmodels.classes.DefaultWrappersModel) Test(org.junit.Test)

Aggregations

Resource (org.apache.sling.api.resource.Resource)1 ValueMap (org.apache.sling.api.resource.ValueMap)1 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)1 DefaultWrappersModel (org.apache.sling.models.testmodels.classes.DefaultWrappersModel)1 Test (org.junit.Test)1