SearchManagerImpl implements SearchManager { @Override public Collection<Feature> getFeaturesByQuery(String appIdentifier, String query, LayerDTO layer, Integer pageIndex, Integer pageSize) throws QueryException { Collection<Feature> collectionFeatures=null; switch (layer) { case ALL: { collectionFeatures=featureRepository.searchIDAppAndQuery(appIdentifier, query, pageIndex, pageSize); Collection<Feature> collectionMap=mapRepository.searchIDAppAndQuery(appIdentifier, query, pageIndex, pageSize); collectionFeatures.addAll(collectionMap); break; } case FEATURES: { collectionFeatures=featureRepository.searchIDAppAndQuery(appIdentifier, query, pageIndex, pageSize); break; } case MAP: { collectionFeatures=mapRepository.searchIDAppAndQuery(appIdentifier, query, pageIndex, pageSize); break; } } return collectionFeatures; }  @Override Feature getRoomByLocation(String appIdentifier, Double longitude, Double latitude, Integer floor); @Override Collection<Feature> getFeaturesByQuery(String appIdentifier,
			String query, LayerDTO layer, Integer pageIndex, Integer pageSize); @Override Collection<Feature> getFeaturesByQuery(String appIdentifier,
			String query, LayerDTO layer, Integer pageIndex, Integer pageSize,
			String orderField, String order);  }
@Test public void getFeaturesByQueryAllTest() throws QueryException{ String idApplication = "9"; String query ="query"; Integer pageIndex=5; Integer pageSize= 20; LayerDTO layerDTO=LayerDTO.ALL; Mockito.when(featureRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize)).thenReturn(collectionFeatures); Mockito.when(mapRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize)).thenReturn(collectionMap); searchManagerImpl.getFeaturesByQuery(idApplication, query, layerDTO, pageIndex, pageSize); Mockito.verify(featureRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize); Mockito.verify(mapRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize); Mockito.verify(collectionFeatures).addAll(collectionMap); }
@Test public void getFeaturesByQueryFeaturesTest() throws QueryException{ String idApplication = "9"; String query ="query"; Integer pageIndex=5; Integer pageSize= 20; LayerDTO layerDTO=LayerDTO.FEATURES; Mockito.when(featureRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize)).thenReturn(collectionFeatures); searchManagerImpl.getFeaturesByQuery(idApplication, query, layerDTO, pageIndex, pageSize); Mockito.verify(featureRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize); }
@Test public void getFeaturesByQueryMapTest() throws QueryException{ String idApplication = "9"; String query ="query"; Integer pageIndex=5; Integer pageSize= 20; LayerDTO layerDTO=LayerDTO.MAP; Mockito.when(mapRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize)).thenReturn(collectionFeatures); searchManagerImpl.getFeaturesByQuery(idApplication, query, layerDTO, pageIndex, pageSize); Mockito.verify(mapRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize); }
@Test public void getFeaturesByQueryAllWithOrderTest() throws QueryException{ String idApplication = "9"; String query ="query"; Integer pageIndex=5; Integer pageSize= 20; LayerDTO layerDTO=LayerDTO.ALL; String orderField="field"; String order="ASC"; Mockito.when(featureRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize, orderField, order)).thenReturn(collectionFeatures); Mockito.when(mapRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize, orderField, order)).thenReturn(collectionMap); searchManagerImpl.getFeaturesByQuery(idApplication, query, layerDTO, pageIndex, pageSize, orderField, order); Mockito.verify(featureRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize, orderField, order); Mockito.verify(mapRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize, orderField, order); Mockito.verify(collectionFeatures).addAll(collectionMap); }
@Test public void getFeaturesByQueryFeaturesWithOrderTest() throws QueryException{ String idApplication = "9"; String query ="query"; Integer pageIndex=5; Integer pageSize= 20; LayerDTO layerDTO=LayerDTO.FEATURES; String orderField="field"; String order="ASC"; Mockito.when(featureRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize, orderField, order)).thenReturn(collectionFeatures); searchManagerImpl.getFeaturesByQuery(idApplication, query, layerDTO, pageIndex, pageSize, orderField, order); Mockito.verify(featureRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize, orderField, order); }
@Test public void getFeaturesByQueryMapWithOrderTest() throws QueryException{ String idApplication = "9"; String query ="query"; Integer pageIndex=5; Integer pageSize= 20; LayerDTO layerDTO=LayerDTO.MAP; String orderField="field"; String order="ASC"; Mockito.when(mapRepository.searchIDAppAndQuery(idApplication,query, pageIndex, pageSize, orderField, order)).thenReturn(collectionFeatures); searchManagerImpl.getFeaturesByQuery(idApplication, query, layerDTO, pageIndex, pageSize, orderField, order); Mockito.verify(mapRepository).searchIDAppAndQuery(idApplication, query, pageIndex, pageSize, orderField, order); }