diff --git a/NEWS.md b/NEWS.md index 07d6b90f..9db40f6a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,7 @@ * Sanitize HTML content for the package description field ([MODKBEKBJ-860](https://folio-org.atlassian.net/browse/MODKBEKBJ-860)) * Validate blank package url and remove invalid format checks ([MODKBEKBJ-863](https://folio-org.atlassian.net/browse/MODKBEKBJ-863)) * Add managed and custom subjects to package detail record ([MODKBEKBJ-853](https://folio-org.atlassian.net/browse/MODKBEKBJ-853)) +* Support visibleSomewhere and hiddenSomewhere for package visibility filter ([MODKBEKBJ-865](https://folio-org.atlassian.net/browse/MODKBEKBJ-865)) ### Bug fixes * Fix offset handling when retrieving holdings from HoldingsIQ. ([MODKBEKBJ-825](https://folio-org.atlassian.net/browse/MODKBEKBJ-825)) diff --git a/ramls/traits/packageFilterable.raml b/ramls/traits/packageFilterable.raml index 7b493355..8727279f 100644 --- a/ramls/traits/packageFilterable.raml +++ b/ramls/traits/packageFilterable.raml @@ -20,7 +20,7 @@ queryParameters: description: | Limits the results based on customer visibility status per product category. Only functions when selection=selected is included in the request. - Possible values: visibleInPF, visibleInFTF, visibleInMARC, hiddenInPF, hiddenInFTF, hiddenInMARC + Possible values: visibleInPF, visibleInFTF, visibleInMARC, visibleSomewhere, hiddenInPF, hiddenInFTF, hiddenInMARC, hiddenSomewhere example: visibleInPF required: false filter[access]: diff --git a/src/main/java/org/folio/rest/util/RestConstants.java b/src/main/java/org/folio/rest/util/RestConstants.java index 4e61c9aa..1aabefab 100644 --- a/src/main/java/org/folio/rest/util/RestConstants.java +++ b/src/main/java/org/folio/rest/util/RestConstants.java @@ -34,9 +34,11 @@ public final class RestConstants { "onlinereference", "streamingmedia", "mixedcontent"); public static final Map FILTER_VISIBILITY_MAPPING = - Map.of("visibleInPF", PackageFilterVisibility.VISIBLE_IN_PF, + Map.of("visibleSomewhere", PackageFilterVisibility.VISIBLE_SOMEWHERE, + "visibleInPF", PackageFilterVisibility.VISIBLE_IN_PF, "visibleInFTF", PackageFilterVisibility.VISIBLE_IN_FTF, "visibleInMARC", PackageFilterVisibility.INCLUDED_IN_MARC, + "hiddenSomewhere", PackageFilterVisibility.HIDDEN_SOMEWHERE, "hiddenInPF", PackageFilterVisibility.HIDDEN_IN_PF, "hiddenInFTF", PackageFilterVisibility.HIDDEN_IN_FTF, "hiddenInMARC", PackageFilterVisibility.EXCLUDED_FROM_MARC); diff --git a/src/test/java/org/folio/rest/model/filter/PackageFilterValidatorTest.java b/src/test/java/org/folio/rest/model/filter/PackageFilterValidatorTest.java new file mode 100644 index 00000000..ee8628c2 --- /dev/null +++ b/src/test/java/org/folio/rest/model/filter/PackageFilterValidatorTest.java @@ -0,0 +1,43 @@ +package org.folio.rest.model.filter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.folio.holdingsiq.model.PackageFilterVisibility; +import org.folio.rest.exception.QueryParamsValidationException; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +class PackageFilterValidatorTest { + + @ParameterizedTest + @CsvSource({ + "visibleInPF, VISIBLE_IN_PF", + "visibleInFTF, VISIBLE_IN_FTF", + "visibleInMARC, INCLUDED_IN_MARC", + "visibleSomewhere, VISIBLE_SOMEWHERE", + "hiddenInPF, HIDDEN_IN_PF", + "hiddenInFTF, HIDDEN_IN_FTF", + "hiddenInMARC, EXCLUDED_FROM_MARC", + "hiddenSomewhere, HIDDEN_SOMEWHERE" + }) + void shouldAcceptAndMapSupportedVisibilityFilter(String value, PackageFilterVisibility expected) { + var filter = PackageRecordFilter.builder().sort("name").filterSelected("true").filterVisibility(value).build(); + + assertThat(filter.getPackageFilterVisibility()).contains(expected); + } + + @Test + void shouldRejectUnknownVisibilityFilter() { + var builder = PackageRecordFilter.builder().sort("name").filterVisibility("hiddenNowhere"); + + assertThatThrownBy(builder::build).isInstanceOf(QueryParamsValidationException.class); + } + + @Test + void shouldAcceptMissingVisibilityFilter() { + assertThatCode(() -> PackageRecordFilter.builder().sort("name").build()).doesNotThrowAnyException(); + } +}