Search in sources :

Example 1 with DefaultPrimitivesModel

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

the class DefaultTest method testDefaultPrimitivesField.

@Test
public void testDefaultPrimitivesField() {
    ValueMap vm = new ValueMapDecorator(Collections.<String, Object>emptyMap());
    Resource res = mock(Resource.class);
    when(res.adaptTo(ValueMap.class)).thenReturn(vm);
    DefaultPrimitivesModel model = factory.getAdapter(res, DefaultPrimitivesModel.class);
    assertNotNull(model);
    assertEquals(true, model.getBooleanProperty());
    // 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[] { true, true }, model.getBooleanArrayProperty()));
    assertEquals(1L, model.getLongProperty());
    assertArrayEquals(new long[] { 1L, 1L }, model.getLongArrayProperty());
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) ValueMapDecorator(org.apache.sling.api.wrappers.ValueMapDecorator) Resource(org.apache.sling.api.resource.Resource) DefaultPrimitivesModel(org.apache.sling.models.testmodels.classes.DefaultPrimitivesModel) 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 DefaultPrimitivesModel (org.apache.sling.models.testmodels.classes.DefaultPrimitivesModel)1 Test (org.junit.Test)1