@Test public void testStructureDepthProperty() { 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(); Assert.assertEquals(DEFAULT_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth")); 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")); 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")); 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")); properties.put(PN_STRUCTURE_DEPTH, MIN_STRUCTURE_DEPTH - 1); navigation.initModel(); Assert.assertEquals(MIN_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth")); properties.put(PN_STRUCTURE_DEPTH, MAX_STRUCTURE_DEPTH + 1); navigation.initModel(); Assert.assertEquals(MAX_STRUCTURE_DEPTH, Whitebox.getInternalState(navigation, "structureDepth")); properties.put(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH + 1); navigation.initModel(); Assert.assertEquals(DEFAULT_STRUCTURE_DEPTH + 1, Whitebox.getInternalState(navigation, "structureDepth")); }
@PostConstruct void initModel() { graphQLCategoryProvider = new GraphQLCategoryProvider(resource, currentPage); structureDepth = properties.get(PN_STRUCTURE_DEPTH, currentStyle.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)); if (structureDepth < MIN_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is bellow min value ({}). Using min value.", PN_STRUCTURE_DEPTH, MIN_STRUCTURE_DEPTH); structureDepth = MIN_STRUCTURE_DEPTH; } if (structureDepth > MAX_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is above max value ({}). Using max value.", PN_STRUCTURE_DEPTH, MAX_STRUCTURE_DEPTH); structureDepth = MAX_STRUCTURE_DEPTH; } }
NavigationImpl implements Navigation { @PostConstruct void initModel() { graphQLCategoryProvider = new GraphQLCategoryProvider(resource, currentPage); structureDepth = properties.get(PN_STRUCTURE_DEPTH, currentStyle.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)); if (structureDepth < MIN_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is bellow min value ({}). Using min value.", PN_STRUCTURE_DEPTH, MIN_STRUCTURE_DEPTH); structureDepth = MIN_STRUCTURE_DEPTH; } if (structureDepth > MAX_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is above max value ({}). Using max value.", PN_STRUCTURE_DEPTH, MAX_STRUCTURE_DEPTH); structureDepth = MAX_STRUCTURE_DEPTH; } } }
NavigationImpl implements Navigation { @PostConstruct void initModel() { graphQLCategoryProvider = new GraphQLCategoryProvider(resource, currentPage); structureDepth = properties.get(PN_STRUCTURE_DEPTH, currentStyle.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)); if (structureDepth < MIN_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is bellow min value ({}). Using min value.", PN_STRUCTURE_DEPTH, MIN_STRUCTURE_DEPTH); structureDepth = MIN_STRUCTURE_DEPTH; } if (structureDepth > MAX_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is above max value ({}). Using max value.", PN_STRUCTURE_DEPTH, MAX_STRUCTURE_DEPTH); structureDepth = MAX_STRUCTURE_DEPTH; } }  }
NavigationImpl implements Navigation { @PostConstruct void initModel() { graphQLCategoryProvider = new GraphQLCategoryProvider(resource, currentPage); structureDepth = properties.get(PN_STRUCTURE_DEPTH, currentStyle.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)); if (structureDepth < MIN_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is bellow min value ({}). Using min value.", PN_STRUCTURE_DEPTH, MIN_STRUCTURE_DEPTH); structureDepth = MIN_STRUCTURE_DEPTH; } if (structureDepth > MAX_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is above max value ({}). Using max value.", PN_STRUCTURE_DEPTH, MAX_STRUCTURE_DEPTH); structureDepth = MAX_STRUCTURE_DEPTH; } }  @Override List<NavigationItem> getItems(); @Override String getId(); @Override String getParentId(); }
NavigationImpl implements Navigation { @PostConstruct void initModel() { graphQLCategoryProvider = new GraphQLCategoryProvider(resource, currentPage); structureDepth = properties.get(PN_STRUCTURE_DEPTH, currentStyle.get(PN_STRUCTURE_DEPTH, DEFAULT_STRUCTURE_DEPTH)); if (structureDepth < MIN_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is bellow min value ({}). Using min value.", PN_STRUCTURE_DEPTH, MIN_STRUCTURE_DEPTH); structureDepth = MIN_STRUCTURE_DEPTH; } if (structureDepth > MAX_STRUCTURE_DEPTH) { LOGGER.warn("Navigation structure depth ({}) is above max value ({}). Using max value.", PN_STRUCTURE_DEPTH, MAX_STRUCTURE_DEPTH); structureDepth = MAX_STRUCTURE_DEPTH; } }  @Override List<NavigationItem> getItems(); @Override String getId(); @Override String getParentId();  }