diff --git a/src/main/java/org/folio/fqm/client/SimpleHttpClient.java b/src/main/java/org/folio/fqm/client/SimpleHttpClient.java index 3ca43242..3269f206 100644 --- a/src/main/java/org/folio/fqm/client/SimpleHttpClient.java +++ b/src/main/java/org/folio/fqm/client/SimpleHttpClient.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; import java.util.Map; @@ -21,4 +22,15 @@ public interface SimpleHttpClient { */ @GetMapping(value = "/{path}", produces = MediaType.APPLICATION_JSON_VALUE) String get(@PathVariable String path, @SpringQueryMap Map queryParams); + + /** + * Retrieve arbitrary data from a FOLIO API endpoint for the specified tenant. + * + * @param path - the path of the API endpoint + * @param queryParams - a map of query parameters to pass to the API endpoint + * @param tenant - FOLIO tenant from which to retrieve data + * @return the body of the response (JSON) + */ + @GetMapping(value = "/{path}?{queryParams}", produces = MediaType.APPLICATION_JSON_VALUE) + String get(@PathVariable String path, @SpringQueryMap Map queryParams, @RequestHeader("X-Okapi-Tenant") String tenant); } diff --git a/src/main/java/org/folio/fqm/repository/IdStreamer.java b/src/main/java/org/folio/fqm/repository/IdStreamer.java index b314c49d..9ebb96ee 100644 --- a/src/main/java/org/folio/fqm/repository/IdStreamer.java +++ b/src/main/java/org/folio/fqm/repository/IdStreamer.java @@ -56,7 +56,7 @@ public int streamIdsInBatch(EntityType entityType, int batchSize, Consumer idsConsumer) { boolean ecsEnabled = crossTenantQueryService.ecsEnabled(); - List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType, false); + List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType); return this.streamIdsInBatch(entityType, sortResults, fql, batchSize, idsConsumer, tenantsToQuery, ecsEnabled); } diff --git a/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java b/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java index c2e97abc..045bf5ad 100644 --- a/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java +++ b/src/main/java/org/folio/fqm/service/CrossTenantQueryService.java @@ -26,13 +26,35 @@ public class CrossTenantQueryService { private static final String COMPOSITE_INSTANCES_ID = "6b08439b-4f8e-4468-8046-ea620f5cfb74"; private static final String SIMPLE_INSTANCES_ID = "8fc4a9d2-7ccf-4233-afb8-796911839862"; + private static final String SIMPLE_INSTANCE_STATUS_ID = "9c239bfd-198f-4013-bbc4-4551c0cbdeaa"; + private static final String SIMPLE_INSTANCE_TYPE_ID = "af44e2e0-12e0-4eec-b80d-49feb33a866c"; + private static final List INSTANCE_RELATED_ENTITIES = List.of(SIMPLE_INSTANCES_ID, COMPOSITE_INSTANCES_ID, SIMPLE_INSTANCE_STATUS_ID, SIMPLE_INSTANCE_TYPE_ID); - public List getTenantsToQuery(EntityType entityType, boolean forceCrossTenantQuery) { - if (!forceCrossTenantQuery - && !Boolean.TRUE.equals(entityType.getCrossTenantQueriesEnabled()) + /** + * Retrieve list of tenants to run query against. + * @param entityType Entity type definition + * @return List of tenants to query + */ + public List getTenantsToQuery(EntityType entityType) { + if (!Boolean.TRUE.equals(entityType.getCrossTenantQueriesEnabled()) && !COMPOSITE_INSTANCES_ID.equals(entityType.getId())) { return List.of(executionContext.getTenantId()); } + return getTenants(entityType); + } + + /** + * Retrieve list of tenants to retrieve column values from. This method skips the cross-tenant query check, since the + * column values API uses simple entity type definitions, which don't have cross-tenant queries enabled. + * method skips the cross-tenant query check + * @param entityType Entity type definition + * @return List of tenants to query + */ + public List getTenantsToQueryForColumnValues(EntityType entityType) { + return getTenants(entityType); + } + + private List getTenants(EntityType entityType) { // Get the ECS tenant info first, since this comes from mod-users and should work in non-ECS environments // We can use this for determining if it's an ECS environment, and if so, retrieving the consortium ID and central tenant ID Map ecsTenantInfo = getEcsTenantInfo(); @@ -46,7 +68,7 @@ public List getTenantsToQuery(EntityType entityType, boolean forceCrossT // The Instances entity type is required to retrieve shared instances from the central tenant when // running queries from member tenants. This means that if we are running a query for Instances, we need to // query the current tenant (for local records) as well as the central tenant (for shared records). - if (COMPOSITE_INSTANCES_ID.equals(entityType.getId()) || SIMPLE_INSTANCES_ID.equals(entityType.getId())) { + if (INSTANCE_RELATED_ENTITIES.contains(entityType.getId())) { return List.of(executionContext.getTenantId(), centralTenantId); } return List.of(executionContext.getTenantId()); diff --git a/src/main/java/org/folio/fqm/service/EntityTypeService.java b/src/main/java/org/folio/fqm/service/EntityTypeService.java index 07f9f662..fb38d4b2 100644 --- a/src/main/java/org/folio/fqm/service/EntityTypeService.java +++ b/src/main/java/org/folio/fqm/service/EntityTypeService.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; +import feign.FeignException; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.codehaus.plexus.util.StringUtils; @@ -22,7 +23,6 @@ import org.folio.querytool.domain.dto.EntityTypeColumn; import org.folio.querytool.domain.dto.Field; import org.folio.querytool.domain.dto.SourceColumn; -import org.folio.querytool.domain.dto.ValueSourceApi; import org.folio.querytool.domain.dto.ValueWithLabel; import org.springframework.lang.Nullable; import org.springframework.stereotype.Service; @@ -140,8 +140,9 @@ public ColumnValues getFieldValues(UUID entityTypeId, String fieldName, @Nullabl return getFieldValuesFromEntityTypeDefinition(field, searchText); } + List tenantsToQuery = crossTenantQueryService.getTenantsToQueryForColumnValues(entityType); if (field.getValueSourceApi() != null) { - return getFieldValuesFromApi(field, searchText); + return getFieldValuesFromApi(field, searchText, tenantsToQuery); } if (field.getSource() != null) { @@ -160,7 +161,7 @@ public ColumnValues getFieldValues(UUID entityTypeId, String fieldName, @Nullabl return getTenantIds(entityType); } case "languages" -> { - return getLanguages(searchText); + return getLanguages(searchText, tenantsToQuery); } default -> { throw new InvalidEntityTypeDefinitionException("Unhandled source name \"" + field.getSource().getName() + "\" for the FQM value source type in column \"" + fieldName + '"', entityType); @@ -173,7 +174,7 @@ public ColumnValues getFieldValues(UUID entityTypeId, String fieldName, @Nullabl } private ColumnValues getTenantIds(EntityType entityType) { - List tenants = crossTenantQueryService.getTenantsToQuery(entityType, true); + List tenants = crossTenantQueryService.getTenantsToQueryForColumnValues(entityType); List tenantValues = tenants .stream() .map(tenant -> new ValueWithLabel().value(tenant).label(tenant)) @@ -192,22 +193,28 @@ private ColumnValues getFieldValuesFromEntityTypeDefinition(Field field, String return new ColumnValues().content(filteredValues); } - private ColumnValues getFieldValuesFromApi(Field field, String searchText) { - Map queryParams = new HashMap<>(Map.of("limit", String.valueOf(COLUMN_VALUE_DEFAULT_PAGE_SIZE))); - ValueSourceApi valueSourceApi = field.getValueSourceApi(); - String rawJson = simpleHttpClient.get(valueSourceApi.getPath(), queryParams); - DocumentContext parsedJson = JsonPath.parse(rawJson); - List values = parsedJson.read(field.getValueSourceApi().getValueJsonPath()); - List labels = parsedJson.read(field.getValueSourceApi().getLabelJsonPath()); - - List results = new ArrayList<>(values.size()); - for (int i = 0; i < values.size(); i++) { - String value = values.get(i); - String label = labels.get(i); - if (label.contains(searchText)) { - results.add(new ValueWithLabel().value(value).label(label)); + private ColumnValues getFieldValuesFromApi(Field field, String searchText, List tenantsToQuery) { + Set resultSet = new HashSet<>(); + for (String tenantId : tenantsToQuery) { + try { + String rawJson = simpleHttpClient.get(field.getValueSourceApi().getPath(), Map.of("limit", String.valueOf(COLUMN_VALUE_DEFAULT_PAGE_SIZE)), tenantId); + DocumentContext parsedJson = JsonPath.parse(rawJson); + List values = parsedJson.read(field.getValueSourceApi().getValueJsonPath()); + List labels = parsedJson.read(field.getValueSourceApi().getLabelJsonPath()); + for (int i = 0; i < values.size(); i++) { + String value = values.get(i); + String label = labels.get(i); + if (label.contains(searchText)) { + resultSet.add(new ValueWithLabel().value(value).label(label)); + } + } + } catch (FeignException.Unauthorized e) { + log.error("Failed to get column values from {} tenant due to exception: {}", tenantId, e.getMessage()); } } + + + List results = new ArrayList<>(resultSet); results.sort(Comparator.comparing(ValueWithLabel::getLabel, String.CASE_INSENSITIVE_ORDER)); return new ColumnValues().content(results); } @@ -243,15 +250,21 @@ private static ColumnValues getCurrencyValues() { return new ColumnValues().content(currencies); } - private ColumnValues getLanguages(String searchText) { + private ColumnValues getLanguages(String searchText, List tenantsToQuery) { Map queryParams = Map.of( "facet", "languages", "query", "id=*", "limit", "1000" ); - String rawJson = simpleHttpClient.get("search/instances/facets", queryParams); - DocumentContext parsedJson = JsonPath.parse(rawJson); - List values = parsedJson.read("$.facets.languages.values.*.id"); + + Set valueSet = new HashSet<>(); + for (String tenant : tenantsToQuery) { + String rawJson = simpleHttpClient.get("search/instances/facets", queryParams, tenant); + DocumentContext parsedJson = JsonPath.parse(rawJson); + List values = parsedJson.read("$.facets.languages.values.*.id"); + valueSet.addAll(values); + } + List values = new ArrayList<>(valueSet); List results = new ArrayList<>(); ObjectMapper mapper = diff --git a/src/main/java/org/folio/fqm/service/QueryManagementService.java b/src/main/java/org/folio/fqm/service/QueryManagementService.java index 663c9e6d..10a398df 100644 --- a/src/main/java/org/folio/fqm/service/QueryManagementService.java +++ b/src/main/java/org/folio/fqm/service/QueryManagementService.java @@ -191,7 +191,7 @@ public List> getContents(UUID entityTypeId, List fie fields.add(colName); } }); - List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType, false); + List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType); return resultSetService.getResultSet(entityTypeId, fields, ids, tenantsToQuery); } @@ -199,7 +199,7 @@ private List> getContents(UUID queryId, UUID entityTypeId, L if (includeResults) { EntityType entityType = entityTypeService.getEntityTypeDefinition(entityTypeId, true, false); List> resultIds = queryResultsRepository.getQueryResultIds(queryId, offset, limit); - List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType, false); + List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType); return resultSetService.getResultSet(entityTypeId, fields, resultIds, tenantsToQuery); } return List.of(); diff --git a/src/main/java/org/folio/fqm/service/QueryProcessorService.java b/src/main/java/org/folio/fqm/service/QueryProcessorService.java index 7fb1b804..cc05587b 100644 --- a/src/main/java/org/folio/fqm/service/QueryProcessorService.java +++ b/src/main/java/org/folio/fqm/service/QueryProcessorService.java @@ -76,7 +76,7 @@ public void getIdsInBatch(FqlQueryWithContext fqlQueryWithContext, public List> processQuery(EntityType entityType, String fqlQuery, List fields, List afterId, Integer limit) { Fql fql = fqlService.getFql(fqlQuery); boolean ecsEnabled = crossTenantQueryService.ecsEnabled(); - List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType, false); + List tenantsToQuery = crossTenantQueryService.getTenantsToQuery(entityType); return resultSetRepository.getResultSetSync( UUID.fromString(entityType.getId()), fql, diff --git a/src/test/java/org/folio/fqm/service/CrossTenantQueryServiceTest.java b/src/test/java/org/folio/fqm/service/CrossTenantQueryServiceTest.java index ee7d7324..fe02a47c 100644 --- a/src/test/java/org/folio/fqm/service/CrossTenantQueryServiceTest.java +++ b/src/test/java/org/folio/fqm/service/CrossTenantQueryServiceTest.java @@ -24,6 +24,7 @@ class CrossTenantQueryServiceTest { private static final EntityType entityType = new EntityType() + .id(UUID.randomUUID().toString()) .crossTenantQueriesEnabled(true); @Mock @@ -102,7 +103,7 @@ void shouldGetListOfTenantsToQuery() { when(userTenantService.getUserTenantsResponse(tenantId)).thenReturn(ECS_TENANT_INFO); when(ecsClient.get(eq("consortia/bdaa4720-5e11-4632-bc10-d4455cf252df/user-tenants"), anyMap())).thenReturn(USER_TENANT_JSON); - List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType, false); + List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType); assertEquals(expectedTenants, actualTenants); } @@ -112,7 +113,7 @@ void shouldRunIntraTenantQueryForNonInstanceEntityTypes() { List expectedTenants = List.of("tenant_01"); when(executionContext.getTenantId()).thenReturn("tenant_01"); - List actualTenants = crossTenantQueryService.getTenantsToQuery(nonEcsEntityType, false); + List actualTenants = crossTenantQueryService.getTenantsToQuery(nonEcsEntityType); assertEquals(expectedTenants, actualTenants); } @@ -122,7 +123,7 @@ void shouldRunIntraTenantQueryForNonCentralTenant() { List expectedTenants = List.of(tenantId); when(executionContext.getTenantId()).thenReturn(tenantId); // Central is tenant_01 when(userTenantService.getUserTenantsResponse(tenantId)).thenReturn(ECS_TENANT_INFO); - List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType, false); + List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType); assertEquals(expectedTenants, actualTenants); } @@ -132,7 +133,7 @@ void shouldRunIntraTenantQueryIfExceptionIsThrown() { List expectedTenants = List.of(tenantId); when(executionContext.getTenantId()).thenReturn(tenantId); when(userTenantService.getUserTenantsResponse(tenantId)).thenReturn(ECS_TENANT_INFO_FOR_NON_ECS_ENV); - List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType, false); + List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType); assertEquals(expectedTenants, actualTenants); } @@ -144,7 +145,7 @@ void shouldReturnTenantIdOnlyIfUserTenantsApiThrowsException() { when(executionContext.getTenantId()).thenReturn(tenantId); when(userTenantService.getUserTenantsResponse(tenantId)).thenReturn(ECS_TENANT_INFO_FOR_NON_ECS_ENV); - List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType, false); + List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType); assertEquals(expectedTenants, actualTenants); } @@ -156,7 +157,7 @@ void shouldAttemptCrossTenantQueryIfForceParamIsTrue() { when(executionContext.getTenantId()).thenReturn(tenantId); when(userTenantService.getUserTenantsResponse(tenantId)).thenReturn(ECS_TENANT_INFO_FOR_NON_ECS_ENV); - List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType, true); + List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType); verify(userTenantService, times(1)).getUserTenantsResponse(tenantId); assertEquals(expectedTenants, actualTenants); } @@ -171,7 +172,7 @@ void shouldNotQueryTenantIfUserLacksTenantPermissions() { when(ecsClient.get(eq("consortia/bdaa4720-5e11-4632-bc10-d4455cf252df/user-tenants"), anyMap())).thenReturn(USER_TENANT_JSON); doNothing().when(permissionsService).verifyUserHasNecessaryPermissions("tenant_02", entityType, true); doThrow(MissingPermissionsException.class).when(permissionsService).verifyUserHasNecessaryPermissions("tenant_03", entityType, true); - List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType, false); + List actualTenants = crossTenantQueryService.getTenantsToQuery(entityType); assertEquals(expectedTenants, actualTenants); } @@ -186,7 +187,20 @@ void shouldQueryCentralTenantForSharedCompositeInstances() { when(executionContext.getTenantId()).thenReturn(tenantId); when(userTenantService.getUserTenantsResponse(tenantId)).thenReturn(ECS_TENANT_INFO); - List actualTenants = crossTenantQueryService.getTenantsToQuery(instanceEntityType, false); + List actualTenants = crossTenantQueryService.getTenantsToQuery(instanceEntityType); + assertEquals(expectedTenants, actualTenants); + } + + @Test + void shouldGetListOfTenantsToQueryForColumnValues() { + String tenantId = "tenant_01"; + List expectedTenants = List.of("tenant_01", "tenant_02", "tenant_03"); + + when(executionContext.getTenantId()).thenReturn(tenantId); + when(userTenantService.getUserTenantsResponse(tenantId)).thenReturn(ECS_TENANT_INFO); + when(ecsClient.get(eq("consortia/bdaa4720-5e11-4632-bc10-d4455cf252df/user-tenants"), anyMap())).thenReturn(USER_TENANT_JSON); + + List actualTenants = crossTenantQueryService.getTenantsToQueryForColumnValues(entityType); assertEquals(expectedTenants, actualTenants); } diff --git a/src/test/java/org/folio/fqm/service/EntityTypeServiceTest.java b/src/test/java/org/folio/fqm/service/EntityTypeServiceTest.java index 6855b134..a571c2f7 100644 --- a/src/test/java/org/folio/fqm/service/EntityTypeServiceTest.java +++ b/src/test/java/org/folio/fqm/service/EntityTypeServiceTest.java @@ -1,5 +1,6 @@ package org.folio.fqm.service; +import feign.FeignException; import org.folio.fqm.client.SimpleHttpClient; import org.folio.fqm.repository.EntityTypeRepository; import org.folio.fqm.testutil.TestDataFixture; @@ -329,6 +330,7 @@ void shouldRemoveDuplicatePredefinedValues() { void shouldReturnValuesFromApi() { UUID entityTypeId = UUID.randomUUID(); String valueColumnName = "column_name"; + List tenantList = List.of("tenant_01", "tenant_02"); EntityType entityType = new EntityType() .id(entityTypeId.toString()) .name("the entity type") @@ -341,8 +343,9 @@ void shouldReturnValuesFromApi() { ) )); + when(crossTenantQueryService.getTenantsToQueryForColumnValues(entityType)).thenReturn(tenantList); when(entityTypeFlatteningService.getFlattenedEntityType(entityTypeId, null)).thenReturn(entityType); - when(simpleHttpClient.get(eq("fake-path"), anyMap())).thenReturn(""" + when(simpleHttpClient.get(eq("fake-path"), anyMap(), eq("tenant_01"))).thenReturn(""" { "what": { "ever": { @@ -364,6 +367,7 @@ void shouldReturnValuesFromApi() { } } """); + when(simpleHttpClient.get(eq("fake-path"), anyMap(), eq("tenant_02"))).thenThrow(FeignException.Unauthorized.class); ColumnValues actualColumnValueLabel = entityTypeService.getFieldValues(entityTypeId, valueColumnName, "r"); @@ -377,6 +381,7 @@ void shouldReturnValuesFromApi() { @Test void shouldReturnLanguagesFromApi() { UUID entityTypeId = UUID.randomUUID(); + List tenantList = List.of("tenant_01"); String valueColumnName = "languages"; EntityType entityType = new EntityType() .id(entityTypeId.toString()) @@ -389,7 +394,8 @@ void shouldReturnLanguagesFromApi() { )); when(entityTypeFlatteningService.getFlattenedEntityType(entityTypeId, null)).thenReturn(entityType); - when(simpleHttpClient.get(eq("search/instances/facets"), anyMap())).thenReturn(""" + when(crossTenantQueryService.getTenantsToQueryForColumnValues(entityType)).thenReturn(tenantList); + when(simpleHttpClient.get(eq("search/instances/facets"), anyMap(), eq("tenant_01"))).thenReturn(""" { "facets": { "languages": { @@ -430,6 +436,7 @@ void shouldReturnLanguagesFromApi() { @Test void shouldReturnLocalizedLanguagesFromApi() { UUID entityTypeId = UUID.randomUUID(); + List tenantList = List.of("tenant_01"); String valueColumnName = "languages"; EntityType entityType = new EntityType() .id(entityTypeId.toString()) @@ -442,7 +449,8 @@ void shouldReturnLocalizedLanguagesFromApi() { )); when(entityTypeFlatteningService.getFlattenedEntityType(entityTypeId, null)).thenReturn(entityType); - when(simpleHttpClient.get(eq("search/instances/facets"), anyMap())).thenReturn(""" + when(crossTenantQueryService.getTenantsToQueryForColumnValues(entityType)).thenReturn(tenantList); + when(simpleHttpClient.get(eq("search/instances/facets"), anyMap(), eq("tenant_01"))).thenReturn(""" { "facets": { "languages": { @@ -575,6 +583,7 @@ void shouldReturnCurrencies() { void shouldReturnTenantId() { UUID entityTypeId = UUID.randomUUID(); String valueColumnName = "this_is_a_tenant_id_column"; + List tenantList = List.of("tenant1", "tenant2"); EntityType entityType = new EntityType() .id(entityTypeId.toString()) .name("tenant-id-test") @@ -586,7 +595,7 @@ void shouldReturnTenantId() { )); when(entityTypeFlatteningService.getFlattenedEntityType(entityTypeId, null)).thenReturn(entityType); - when(crossTenantQueryService.getTenantsToQuery(entityType, true)).thenReturn(List.of("tenant1", "tenant2")); + when(crossTenantQueryService.getTenantsToQueryForColumnValues(entityType)).thenReturn(tenantList); List actualColumnValues = entityTypeService .getFieldValues(entityTypeId, valueColumnName, "") @@ -612,7 +621,7 @@ void shouldIncludeCentralTenantIdInResponseForSimpleInstanceEntityType() { )); when(entityTypeFlatteningService.getFlattenedEntityType(entityTypeId, null)).thenReturn(entityType); - when(crossTenantQueryService.getTenantsToQuery(entityType, true)).thenReturn(List.of("tenant1", "central")); + when(crossTenantQueryService.getTenantsToQueryForColumnValues(entityType)).thenReturn(List.of("tenant1", "central")); List actualColumnValues = entityTypeService .getFieldValues(entityTypeId, valueColumnName, "") diff --git a/src/test/java/org/folio/fqm/service/QueryManagementServiceTest.java b/src/test/java/org/folio/fqm/service/QueryManagementServiceTest.java index 70a473be..ae0071b1 100644 --- a/src/test/java/org/folio/fqm/service/QueryManagementServiceTest.java +++ b/src/test/java/org/folio/fqm/service/QueryManagementServiceTest.java @@ -239,7 +239,7 @@ void shouldReturnQueryDetailsWithContents() { when(queryRepository.getQuery(expectedQuery.queryId(), false)).thenReturn(Optional.of(expectedQuery)); when(queryResultsRepository.getQueryResultsCount(expectedQuery.queryId())).thenReturn(2); when(queryResultsRepository.getQueryResultIds(expectedQuery.queryId(), offset, limit)).thenReturn(resultIds); - when(crossTenantQueryService.getTenantsToQuery(any(), eq(false))).thenReturn(tenantIds); + when(crossTenantQueryService.getTenantsToQuery(any())).thenReturn(tenantIds); when(resultSetService.getResultSet(expectedQuery.entityTypeId(), expectedQuery.fields(), resultIds, tenantIds)).thenReturn(contents); Optional actualDetails = queryManagementService.getQuery(expectedQuery.queryId(), includeResults, offset, limit); assertEquals(expectedDetails, actualDetails); @@ -464,7 +464,7 @@ void shouldGetContents() { Map.of("id", UUID.randomUUID(), "field1", "value3", "field2", "value4") ); when(entityTypeService.getEntityTypeDefinition(entityTypeId,true, false)).thenReturn(entityType); - when(crossTenantQueryService.getTenantsToQuery(any(EntityType.class), eq(false))).thenReturn(tenantIds); + when(crossTenantQueryService.getTenantsToQuery(any(EntityType.class))).thenReturn(tenantIds); when(resultSetService.getResultSet(entityTypeId, fields, ids, tenantIds)).thenReturn(expectedContents); List> actualContents = queryManagementService.getContents(entityTypeId, fields, ids); assertEquals(expectedContents, actualContents); @@ -490,7 +490,7 @@ void shouldGetContentsWithIdsIfIdsNotProvided() { Map.of("id", UUID.randomUUID(), "field1", "value3", "field2", "value4") ); when(entityTypeService.getEntityTypeDefinition(entityTypeId, true, false)).thenReturn(entityType); - when(crossTenantQueryService.getTenantsToQuery(any(EntityType.class), eq(false))).thenReturn(tenantIds); + when(crossTenantQueryService.getTenantsToQuery(any(EntityType.class))).thenReturn(tenantIds); when(resultSetService.getResultSet(entityTypeId, expectedFields, ids, tenantIds)).thenReturn(expectedContents); List> actualContents = queryManagementService.getContents(entityTypeId, providedFields, ids); assertEquals(expectedContents, actualContents); diff --git a/src/test/java/org/folio/fqm/service/QueryProcessorServiceTest.java b/src/test/java/org/folio/fqm/service/QueryProcessorServiceTest.java index bdf55165..d1f8d565 100644 --- a/src/test/java/org/folio/fqm/service/QueryProcessorServiceTest.java +++ b/src/test/java/org/folio/fqm/service/QueryProcessorServiceTest.java @@ -117,7 +117,7 @@ void shouldRunSynchronousQueryAndReturnPaginatedResults() { Map.of("field1", "value1", "field2", "value4") ); when(fqlService.getFql(fqlQuery)).thenReturn(expectedFql); - when(crossTenantQueryService.getTenantsToQuery(entityType, false)).thenReturn(tenantIds); + when(crossTenantQueryService.getTenantsToQuery(entityType)).thenReturn(tenantIds); when(resultSetRepository.getResultSetSync(entityTypeId, expectedFql, fields, afterId, limit, tenantIds, false)).thenReturn(expectedContent); List> actualContent = service.processQuery(entityType, fqlQuery, fields, afterId, limit); assertEquals(expectedContent, actualContent);