From 5167563617df8d9cb0ff79f52b03f9d2400618c3 Mon Sep 17 00:00:00 2001 From: "Gantner, Florian Klaus" Date: Mon, 11 Mar 2024 10:24:08 +0100 Subject: [PATCH] search filterfacet isOpenByDefault as facetentry property to FacetsConverter https://github.com/DSpace/DSpace/issues/9404 --- .../org/dspace/app/rest/converter/DiscoverFacetsConverter.java | 1 + .../java/org/dspace/app/rest/matcher/FacetEntryMatcher.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/DiscoverFacetsConverter.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/DiscoverFacetsConverter.java index cbbdc3e9cbec..d099c6016666 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/DiscoverFacetsConverter.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/DiscoverFacetsConverter.java @@ -83,6 +83,7 @@ public void addFacetValues(Context context, final DiscoverResult searchResult, f if (field.exposeMinAndMaxValue()) { handleExposeMinMaxValues(context, field, facetEntry); } + facetEntry.setOpenByDefault(field.isOpenByDefault()); facetEntry.setExposeMinMax(field.exposeMinAndMaxValue()); facetEntry.setFacetType(field.getType()); for (DiscoverResult.FacetResult value : CollectionUtils.emptyIfNull(facetValues)) { diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java index cc15700b924e..7c5f4c7e7fb8 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java @@ -28,6 +28,7 @@ public static Matcher authorFacet(boolean hasNext) { hasJsonPath("$.name", is("author")), hasJsonPath("$.facetType", is("text")), hasJsonPath("$.facetLimit", any(Integer.class)), + hasJsonPath("$.openByDefault", any(Boolean.class)), hasJsonPath("$._links.self.href", containsString("api/discover/facets/author")), hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/author")) ); @@ -40,6 +41,7 @@ public static Matcher authorFacetWithMinMax(boolean hasNext, Str hasJsonPath("$.facetLimit", any(Integer.class)), hasJsonPath("$.minValue", is(min)), hasJsonPath("$.maxValue", is(max)), + hasJsonPath("$.openByDefault", any(Boolean.class)), hasJsonPath("$._links.self.href", containsString("api/discover/facets/author")), hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/author")) );