DataItemServiceFacade { Set<Class<? extends BaseDimensionalItemObject>> extractTargetEntities( final List<String> filters ) { final Set<Class<? extends BaseDimensionalItemObject>> targetedEntities = new HashSet<>( 0 ); if ( isNotEmpty( filters ) ) { final Iterator<String> iterator = filters.iterator(); while ( iterator.hasNext() ) { final String filter = iterator.next(); final Class<? extends BaseDimensionalItemObject> entity = extractEntityFromEqualFilter( filter ); final Set<Class<? extends BaseDimensionalItemObject>> entities = extractEntitiesFromInFilter( filter ); if ( entity != null || isNotEmpty( entities ) ) { if ( entity != null ) { targetedEntities.add( entity ); } if ( isNotEmpty( entities ) ) { targetedEntities.addAll( entities ); } iterator.remove(); } } } else { targetedEntities.addAll( DATA_TYPE_ENTITY_MAP.values() ); } return targetedEntities; } DataItemServiceFacade( final QueryService queryService );  static final Map<String, Class<? extends BaseDimensionalItemObject>> DATA_TYPE_ENTITY_MAP; }
@Test public void testExtractTargetEntitiesUsingEqualsFilter() { final Set<Class<? extends BaseDimensionalItemObject>> expectedTargetEntities = new HashSet<>( asList( Indicator.class ) ); final List<String> theFilters = newArrayList( "dimensionItemType:eq:INDICATOR" ); final Set<Class<? extends BaseDimensionalItemObject>> actualTargetEntities = dataItemServiceFacade .extractTargetEntities( theFilters ); assertThat( actualTargetEntities, containsInAnyOrder( expectedTargetEntities.toArray() ) ); }
@Test public void testExtractTargetEntitiesUsingInFilter() { final Set<Class<? extends BaseDimensionalItemObject>> expectedTargetEntities = new HashSet<>( asList( Indicator.class, DataSet.class ) ); final List<String> theFilters = newArrayList( "dimensionItemType:in:[INDICATOR, DATA_SET]" ); final Set<Class<? extends BaseDimensionalItemObject>> actualTargetEntities = dataItemServiceFacade .extractTargetEntities( theFilters ); assertThat( actualTargetEntities, containsInAnyOrder( expectedTargetEntities.toArray() ) ); }
@Test public void testExtractTargetEntitiesWhenThereIsNoExplicitTargetSet() { final List<String> noTargetEntitiesFilters = emptyList(); final Set<Class<? extends BaseDimensionalItemObject>> actualTargetEntities = dataItemServiceFacade .extractTargetEntities( noTargetEntitiesFilters ); assertThat( actualTargetEntities, containsInAnyOrder( DATA_TYPE_ENTITY_MAP.values().toArray() ) ); }