@Test public void testSelectUnitsByIdsAndAccessContract_emptySet() throws Exception { AccessContractModel accessContractModel = createAccessContractWithRestrictions(); SelectMultiQuery selectMultiQuery = new SelectMultiQuery(); selectMultiQuery.addQueries(QueryHelper.in(VitamFieldsHelper.id(), "MyId1", "MyId2", "MyId3")); doReturn(buildResponseJsonNode()) .when(metaDataClient).selectUnits((any())); Set<String> foundIds = unitGraphInfoLoader .selectUnitsByIdsAndAccessContract(metaDataClient, SetUtils.emptySet(), accessContractModel); assertThat(foundIds).isEmpty(); verifyZeroInteractions(metaDataClient); }
public Set<String> selectUnitsByIdsAndAccessContract(MetaDataClient metaDataClient, Set<String> unitIds, AccessContractModel accessContractModel) throws InvalidParseOperationException, InvalidCreateOperationException, VitamDBException, MetaDataDocumentSizeException, MetaDataExecutionException, MetaDataClientServerException { Set<String> foundUnitIds = new HashSet<>(); for (List<String> ids : ListUtils.partition(new ArrayList<>(unitIds), MAX_ELASTIC_SEARCH_IN_REQUEST_SIZE)) { SelectMultiQuery select = new SelectMultiQuery(); select.setQuery(QueryHelper.in(VitamFieldsHelper.id(), ids.toArray(new String[0]))); foundUnitIds.addAll(selectUnitsByQueryDslAndAccessContract(metaDataClient, select, accessContractModel)); } return foundUnitIds; }
UnitGraphInfoLoader { public Set<String> selectUnitsByIdsAndAccessContract(MetaDataClient metaDataClient, Set<String> unitIds, AccessContractModel accessContractModel) throws InvalidParseOperationException, InvalidCreateOperationException, VitamDBException, MetaDataDocumentSizeException, MetaDataExecutionException, MetaDataClientServerException { Set<String> foundUnitIds = new HashSet<>(); for (List<String> ids : ListUtils.partition(new ArrayList<>(unitIds), MAX_ELASTIC_SEARCH_IN_REQUEST_SIZE)) { SelectMultiQuery select = new SelectMultiQuery(); select.setQuery(QueryHelper.in(VitamFieldsHelper.id(), ids.toArray(new String[0]))); foundUnitIds.addAll(selectUnitsByQueryDslAndAccessContract(metaDataClient, select, accessContractModel)); } return foundUnitIds; } }
UnitGraphInfoLoader { public Set<String> selectUnitsByIdsAndAccessContract(MetaDataClient metaDataClient, Set<String> unitIds, AccessContractModel accessContractModel) throws InvalidParseOperationException, InvalidCreateOperationException, VitamDBException, MetaDataDocumentSizeException, MetaDataExecutionException, MetaDataClientServerException { Set<String> foundUnitIds = new HashSet<>(); for (List<String> ids : ListUtils.partition(new ArrayList<>(unitIds), MAX_ELASTIC_SEARCH_IN_REQUEST_SIZE)) { SelectMultiQuery select = new SelectMultiQuery(); select.setQuery(QueryHelper.in(VitamFieldsHelper.id(), ids.toArray(new String[0]))); foundUnitIds.addAll(selectUnitsByQueryDslAndAccessContract(metaDataClient, select, accessContractModel)); } return foundUnitIds; }  }
UnitGraphInfoLoader { public Set<String> selectUnitsByIdsAndAccessContract(MetaDataClient metaDataClient, Set<String> unitIds, AccessContractModel accessContractModel) throws InvalidParseOperationException, InvalidCreateOperationException, VitamDBException, MetaDataDocumentSizeException, MetaDataExecutionException, MetaDataClientServerException { Set<String> foundUnitIds = new HashSet<>(); for (List<String> ids : ListUtils.partition(new ArrayList<>(unitIds), MAX_ELASTIC_SEARCH_IN_REQUEST_SIZE)) { SelectMultiQuery select = new SelectMultiQuery(); select.setQuery(QueryHelper.in(VitamFieldsHelper.id(), ids.toArray(new String[0]))); foundUnitIds.addAll(selectUnitsByQueryDslAndAccessContract(metaDataClient, select, accessContractModel)); } return foundUnitIds; }  Set<String> selectUnitsByQueryDslAndAccessContract(MetaDataClient metaDataClient,
        SelectMultiQuery select, AccessContractModel accessContractModel); Set<String> selectUnitsByIdsAndAccessContract(MetaDataClient metaDataClient, Set<String> unitIds,
        AccessContractModel accessContractModel); Map<String, UnitGraphInfo> selectAllUnitGraphByIds(MetaDataClient metaDataClient, Set<String> unitIds); }
UnitGraphInfoLoader { public Set<String> selectUnitsByIdsAndAccessContract(MetaDataClient metaDataClient, Set<String> unitIds, AccessContractModel accessContractModel) throws InvalidParseOperationException, InvalidCreateOperationException, VitamDBException, MetaDataDocumentSizeException, MetaDataExecutionException, MetaDataClientServerException { Set<String> foundUnitIds = new HashSet<>(); for (List<String> ids : ListUtils.partition(new ArrayList<>(unitIds), MAX_ELASTIC_SEARCH_IN_REQUEST_SIZE)) { SelectMultiQuery select = new SelectMultiQuery(); select.setQuery(QueryHelper.in(VitamFieldsHelper.id(), ids.toArray(new String[0]))); foundUnitIds.addAll(selectUnitsByQueryDslAndAccessContract(metaDataClient, select, accessContractModel)); } return foundUnitIds; }  Set<String> selectUnitsByQueryDslAndAccessContract(MetaDataClient metaDataClient,
        SelectMultiQuery select, AccessContractModel accessContractModel); Set<String> selectUnitsByIdsAndAccessContract(MetaDataClient metaDataClient, Set<String> unitIds,
        AccessContractModel accessContractModel); Map<String, UnitGraphInfo> selectAllUnitGraphByIds(MetaDataClient metaDataClient, Set<String> unitIds);  }