Java Code Examples for org.apache.sling.api.wrappers.ValueMapDecorator#put()

The following examples show how to use org.apache.sling.api.wrappers.ValueMapDecorator#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphqlClientDataSourceServlet.java    From aem-core-cif-components with Apache License 2.0 4 votes vote down vote up
private void initValueMap() {
    valueMap = new ValueMapDecorator(new HashMap<String, Object>());
    valueMap.put(PN_VALUE, getValue());
    valueMap.put(PN_TEXT, getText());
}
 
Example 2
Source File: NavigationImplTest.java    From aem-core-cif-components with Apache License 2.0 4 votes vote down vote up
@Test
public void testStructureDepthProperty() {

    // set up
    ValueMapDecorator properties = new ValueMapDecorator(new HashMap<>());
    Whitebox.setInternalState(navigation, "properties", properties);
    Style style = mock(Style.class);
    Whitebox.setInternalState(navigation, "currentStyle", style);
    when(style.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)).thenReturn(DEFAULT_STRUCTURE_DEPTH);
    navigation.initModel();

    // structure depth not in properties or style
    Assert.assertEquals(DEFAULT_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth"));

    // structure depth in style bellow min value
    when(style.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)).thenReturn(MIN_STRUCTURE_DEPTH - 1);
    navigation.initModel();

    Assert.assertEquals(MIN_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth"));

    // structure depth in style above max value
    when(style.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)).thenReturn(MAX_STRUCTURE_DEPTH + 1);
    navigation.initModel();

    Assert.assertEquals(MAX_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth"));

    // structure depth in style OK
    when(style.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)).thenReturn(DEFAULT_STRUCTURE_DEPTH + 1);
    navigation.initModel();

    Assert.assertEquals(DEFAULT_STRUCTURE_DEPTH + 1, Whitebox.getInternalState(navigation, "structureDepth"));

    // structure depth in properties bellow min value
    properties.put(PN_STRUCTURE_DEPTH, MIN_STRUCTURE_DEPTH - 1);
    navigation.initModel();

    Assert.assertEquals(MIN_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth"));

    // structure depth in properties above max value
    properties.put(PN_STRUCTURE_DEPTH, MAX_STRUCTURE_DEPTH + 1);
    navigation.initModel();

    Assert.assertEquals(MAX_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth"));

    // structure depth in properties OK
    properties.put(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH + 1);
    navigation.initModel();

    Assert.assertEquals(DEFAULT_STRUCTURE_DEPTH + 1, Whitebox.getInternalState(navigation, "structureDepth"));
}