DataItemServiceFacade { List<BaseDimensionalItemObject> retrieveDataItemEntities( final Set<Class<? extends BaseDimensionalItemObject>> targetEntities, final List<String> filters, final WebOptions options, final OrderParams orderParams ) { List<BaseDimensionalItemObject> dimensionalItems = new ArrayList<>( 0 ); if ( isNotEmpty( targetEntities ) ) { for ( final Class<? extends BaseDimensionalItemObject> entity : targetEntities ) { final Query query = buildQueryForEntity( entity, filters, options ); dimensionalItems.addAll( executeQuery( query ) ); } sort( dimensionalItems, orderParams ); dimensionalItems = slice( options, dimensionalItems ); } return dimensionalItems; } DataItemServiceFacade( final QueryService queryService );  static final Map<String, Class<? extends BaseDimensionalItemObject>> DATA_TYPE_ENTITY_MAP; }
@Test public void testRetrieveDataItemEntities() { final Set<Class<? extends BaseDimensionalItemObject>> anyTargetEntities = new HashSet<>( asList( Indicator.class ) ); final List<BaseDimensionalItemObject> expectedItemsFound = asList( new Indicator(), new Indicator() ); final List<String> anyFilters = asList( "anyFilter" ); final WebOptions anyWebOptions = mockWebOptions( 10, 1 ); final Set<String> anyOrdering = new HashSet<>( asList( "name:desc" ) ); final OrderParams anyOrderParams = new OrderParams( anyOrdering ); final Query anyQuery = from( new Schema( Indicator.class, "indicator", "indicators" ) ); when( queryService.getQueryFromUrl( any(), anyList(), anyList(), any( Pagination.class ), any( Type.class ) ) ).thenReturn( anyQuery ); when( (List<BaseDimensionalItemObject>) queryService.query( any( Query.class ) ) ) .thenReturn( expectedItemsFound ); final List<BaseDimensionalItemObject> actualDimensionalItems = dataItemServiceFacade .retrieveDataItemEntities( anyTargetEntities, anyFilters, anyWebOptions, anyOrderParams ); assertThat( actualDimensionalItems, containsInAnyOrder( expectedItemsFound.toArray() ) ); }
@Test public void testRetrieveDataItemEntitiesWhenTargetEntitiesIsEmpty() { final Set<Class<? extends BaseDimensionalItemObject>> anyTargetEntities = emptySet(); final List<BaseDimensionalItemObject> expectedItemsFound = asList( new Indicator(), new Indicator() ); final List<String> anyFilters = asList( "anyFilter" ); final WebOptions anyWebOptions = mockWebOptions( 10, 1 ); final Set<String> anyOrdering = new HashSet<>( asList( "name:desc" ) ); final OrderParams anyOrderParams = new OrderParams( anyOrdering ); final Query anyQuery = from( new Schema( Indicator.class, "indicator", "indicators" ) ); when( queryService.getQueryFromUrl( any(), anyList(), anyList(), any( Pagination.class ), any( Type.class ) ) ).thenReturn( anyQuery ); when( (List<BaseDimensionalItemObject>) queryService.query( any( Query.class ) ) ) .thenReturn( expectedItemsFound ); final List<BaseDimensionalItemObject> actualDimensionalItems = dataItemServiceFacade .retrieveDataItemEntities( anyTargetEntities, anyFilters, anyWebOptions, anyOrderParams ); assertThat( actualDimensionalItems, is( empty() ) ); }