From 1c0c0563e7287174627831d5d544e64e9d2eb21f Mon Sep 17 00:00:00 2001 From: Bruno Pacheco Date: Fri, 29 Nov 2024 13:57:07 +0100 Subject: [PATCH] fix: set request parameter to null when there is no variant --- .../beacon/persistence/BeaconDatasetIdsCollector.java | 4 +++- .../beacon/persistence/BeaconIndividualsRequestMapper.java | 2 +- .../beacon/BeaconIndividualsRequestMapperTest.java | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconDatasetIdsCollector.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconDatasetIdsCollector.java index bc80c83..bf40425 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconDatasetIdsCollector.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconDatasetIdsCollector.java @@ -23,6 +23,7 @@ import static java.util.Optional.ofNullable; import static java.util.stream.Collectors.toMap; +import static org.apache.commons.lang3.ObjectUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.isNotBlank; @ApplicationScoped @@ -47,7 +48,8 @@ public Map collect(DatasetSearchQuery query, String accessToken var beaconQuery = BeaconIndividualsRequestMapper.from(query); - if (beaconAuthorization == null || beaconQuery.getQuery().getFilters().isEmpty()) { + if (beaconAuthorization == null || (isEmpty(beaconQuery.getQuery().getFilters()) && + isEmpty(beaconQuery.getQuery().getRequestParameters()))) { return null; } diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconIndividualsRequestMapper.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconIndividualsRequestMapper.java index 079a12c..c6d3f67 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconIndividualsRequestMapper.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconIndividualsRequestMapper.java @@ -61,7 +61,7 @@ public BeaconIndividualsRequest from( .testMode(false) .pagination(new BeaconIndividualsRequestQueryPagination()) .filters(beaconFilters) - .requestParameters(requestParameters) + .requestParameters(requestParameters.isEmpty() ? null : requestParameters) .build()) .build(); } diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/BeaconIndividualsRequestMapperTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/BeaconIndividualsRequestMapperTest.java index 3cd4116..3e8ed83 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/BeaconIndividualsRequestMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/BeaconIndividualsRequestMapperTest.java @@ -45,7 +45,7 @@ void shouldAcceptNullQuery() { .skip(0) .build()) .filters(List.of()) - .requestParameters(List.of()) + .requestParameters(null) .build()) .build()); } @@ -71,7 +71,7 @@ void shouldAcceptEmptyQuery() { .skip(0) .build()) .filters(List.of()) - .requestParameters(List.of()) + .requestParameters(null) .build()) .build()); } @@ -97,7 +97,7 @@ void shouldAcceptEmptyFacets() { .skip(0) .build()) .filters(List.of()) - .requestParameters(List.of()) + .requestParameters(null) .build()) .build()); }