EnrichedItemDTOMapper { public static EnrichedItemDTO map(Item item, boolean drillDown, @Nullable Predicate<Item> itemFilter, @Nullable UriBuilder uriBuilder, @Nullable Locale locale) { ItemDTO itemDTO = ItemDTOMapper.map(item); return map(item, itemDTO, uriBuilder, drillDown, itemFilter, locale); }  static EnrichedItemDTO map(Item item, boolean drillDown, @Nullable Predicate<Item> itemFilter,
            @Nullable UriBuilder uriBuilder, @Nullable Locale locale);  }
@Test public void testFiltering() { GroupItem group = new GroupItem("TestGroup"); GroupItem subGroup = new GroupItem("TestSubGroup"); GenericItem switchItem = itemFactory.createItem(CoreItemFactory.SWITCH, "TestSwitch"); GenericItem numberItem = itemFactory.createItem(CoreItemFactory.NUMBER, "TestNumber"); GenericItem stringItem = itemFactory.createItem(CoreItemFactory.STRING, "TestString"); if (switchItem != null && numberItem != null && stringItem != null) { group.addMember(subGroup); group.addMember(switchItem); group.addMember(numberItem); subGroup.addMember(stringItem); } EnrichedGroupItemDTO dto = (EnrichedGroupItemDTO) EnrichedItemDTOMapper.map(group, false, null, null, null); assertThat(dto.members.length, is(0)); dto = (EnrichedGroupItemDTO) EnrichedItemDTOMapper.map(group, true, null, null, null); assertThat(dto.members.length, is(3)); assertThat(((EnrichedGroupItemDTO) dto.members[0]).members.length, is(1)); dto = (EnrichedGroupItemDTO) EnrichedItemDTOMapper.map(group, true, i -> CoreItemFactory.NUMBER.equals(i.getType()), null, null); assertThat(dto.members.length, is(1)); dto = (EnrichedGroupItemDTO) EnrichedItemDTOMapper.map(group, true, i -> CoreItemFactory.NUMBER.equals(i.getType()) || i instanceof GroupItem, null, null); assertThat(dto.members.length, is(2)); assertThat(((EnrichedGroupItemDTO) dto.members[0]).members.length, is(0)); dto = (EnrichedGroupItemDTO) EnrichedItemDTOMapper.map(group, true, i -> CoreItemFactory.NUMBER.equals(i.getType()) || i instanceof GroupItem, null, null); assertThat(dto.members.length, is(2)); assertThat(((EnrichedGroupItemDTO) dto.members[0]).members.length, is(0)); dto = (EnrichedGroupItemDTO) EnrichedItemDTOMapper.map(group, true, i -> CoreItemFactory.NUMBER.equals(i.getType()) || i.getType().equals(CoreItemFactory.STRING) || i instanceof GroupItem, null, null); assertThat(dto.members.length, is(2)); assertThat(((EnrichedGroupItemDTO) dto.members[0]).members.length, is(1)); }