@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));
}