Merge branch 'w2p-117126_automated-discovery-test' into w2p-117126_automated-discovery-test-latest-main

This commit is contained in:
Jens Vannerum
2024-08-13 13:01:51 +02:00
8 changed files with 480 additions and 578 deletions

View File

@@ -571,6 +571,10 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService
Set<String> metadataFields = new HashSet<>();
Map<String, List<String>> formsToFields = this.authoritiesFormDefinitions.get(nameVocab);
// Vocabulary is not associated with any form definition, meaning it won't be a browse index
if (formsToFields == null) {
return null;
}
for (Map.Entry<String, List<String>> formToField : formsToFields.entrySet()) {
metadataFields.addAll(formToField.getValue().stream().map(value ->
StringUtils.replace(value, "_", "."))

View File

@@ -102,6 +102,11 @@
<entry key="123456789/discovery-sub-community-2-1" value-ref="discovery-sub-community-2-1"/>
<entry key="123456789/discovery-collection-2-1-1" value-ref="discovery-collection-2-1-1"/>
<entry key="123456789/discovery-collection-2-2-1" value-ref="discovery-collection-2-2-1"/>
<!-- Configuration for the minAndMax of sidebar facets test (DiscoveryRestControllerIT) -->
<!-- Since these tests can not be made dynamic as the rest of the tests -->
<!-- a specific configuration is used that doesn't interfere with the default configuration -->
<entry key="minAndMaxTests" value-ref="minAndMaxTestsConfiguration"/>
</map>
</property>
<property name="toIgnoreMetadataFields">
@@ -146,6 +151,154 @@
</property>
</bean>
<bean id="minAndMaxTestsConfiguration" class="org.dspace.discovery.configuration.DiscoveryConfiguration" scope="prototype">
<!--Which sidebar facets are to be displayed-->
<property name="sidebarFacets">
<list>
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<ref bean="searchFilterContentInOriginalBundle"/>
<ref bean="searchFilterEntityType"/>
</list>
</property>
<!-- Set TagCloud configuration per discovery configuration -->
<property name="tagCloudFacetConfiguration" ref="defaultTagCloudFacetConfiguration"/>
<!--The search filters which can be used on the discovery search page-->
<property name="searchFilters">
<list>
<ref bean="searchFilterTitle" />
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<ref bean="searchFilterContentInOriginalBundle"/>
<ref bean="searchFilterFileNameInOriginalBundle" />
<ref bean="searchFilterFileDescriptionInOriginalBundle" />
<ref bean="searchFilterEntityType"/>
<ref bean="searchFilterIsAuthorOfPublicationRelation"/>
<ref bean="searchFilterIsProjectOfPublicationRelation"/>
<ref bean="searchFilterIsOrgUnitOfPublicationRelation"/>
<ref bean="searchFilterIsPublicationOfJournalIssueRelation"/>
<ref bean="searchFilterIsJournalOfPublicationRelation"/>
</list>
</property>
<!--The sort filters for the discovery search-->
<property name="searchSortConfiguration">
<bean class="org.dspace.discovery.configuration.DiscoverySortConfiguration">
<property name="sortFields">
<list>
<ref bean="sortScore" />
<ref bean="sortTitle" />
<ref bean="sortDateIssued" />
<ref bean="sortDateAccessioned"/>
</list>
</property>
</bean>
</property>
<!--Any default filter queries, these filter queries will be used for all
queries done by discovery for this configuration -->
<property name="defaultFilterQueries">
<list>
<!--Only find items, communities and collections-->
<value>(search.resourcetype:Item AND latestVersion:true) OR search.resourcetype:Collection OR search.resourcetype:Community</value>
<value>-withdrawn:true AND -discoverable:false</value>
</list>
</property>
<!--The configuration for the recent submissions-->
<property name="recentSubmissionConfiguration">
<bean class="org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration">
<property name="metadataSortField" value="dc.date.accessioned" />
<property name="type" value="date"/>
<property name="max" value="20"/>
<!-- If enabled the collection home page will not display metadata but show a pageable list of recent submissions -->
<property name="useAsHomePage" value="false"/>
</bean>
</property>
<!--Default result per page -->
<property name="defaultRpp" value="10" />
<property name="hitHighlightingConfiguration">
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration">
<property name="metadataFields">
<list>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="dc.contributor.author"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="dspace.entity.type"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="person.identifier.jobtitle"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="project.identifier.name"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="dc.description.abstract"/>
<property name="maxSize" value="250"/>
<property name="snippets" value="2"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="dc.title"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="organization.legalName"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="person.givenName"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="person.familyName"/>
<property name="snippets" value="5"/>
</bean>
<!-- By default, full text snippets are disabled, as snippets of embargoed/restricted bitstreams
may appear in search results when the Item is public. See DS-3498
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="project.identifier.status"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="orgunit.identifier.name"/>
<property name="snippets" value="5"/>
</bean>
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
<property name="field" value="orgunit.identifier.description"/>
<property name="maxSize" value="250"/>
<property name="snippets" value="5"/>
</bean>
-->
</list>
</property>
</bean>
</property>
<property name="moreLikeThisConfiguration">
<bean class="org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration">
<property name="similarityMetadataFields">
<list>
<value>dc.title</value>
<value>dc.contributor.author</value>
<value>dc.creator</value>
<value>dc.subject</value>
</list>
</property>
<!--The minimum number of matching terms across the metadata fields above before an item is found as related -->
<property name="minTermFrequency" value="5"/>
<!--The maximum number of related items displayed-->
<property name="max" value="3"/>
<!--The minimum word length below which words will be ignored-->
<property name="minWordLength" value="5"/>
</bean>
</property>
<!-- When true a "did you mean" example will be displayed, value can be true or false -->
<property name="spellCheckEnabled" value="true"/>
</bean>
<bean id="discovery-parent-community-1" class="org.dspace.discovery.configuration.DiscoveryConfiguration" scope="prototype">
<property name="id" value="discovery-parent-community-1"/>
<!--Which sidebar facets are to be displayed-->

View File

@@ -7,6 +7,8 @@
*/
package org.dspace.app.rest;
import static org.dspace.app.rest.matcher.BrowseIndexMatcher.bis;
import static org.dspace.app.rest.matcher.BrowseIndexMatcher.browseMatchers;
import static org.dspace.app.rest.matcher.MetadataMatcher.matchMetadata;
import static org.dspace.app.rest.model.BrowseIndexRest.BROWSE_TYPE_VALUE_LIST;
import static org.hamcrest.Matchers.contains;
@@ -66,24 +68,18 @@ public class BrowsesResourceControllerIT extends AbstractControllerIntegrationTe
//We expect the content type to be "application/hal+json;charset=UTF-8"
.andExpect(content().contentType(contentType))
//Our default Discovery config has 5 browse indexes, so we expect this to be reflected in the page
// object
// Dynamically obtain the total number of browse indices configured in dspace.cfg and check that the
// response contains the correct number of browse indices
.andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", is(5)))
.andExpect(jsonPath("$.page.totalElements", is(bis.length)))
.andExpect(jsonPath("$.page.totalPages", is(1)))
.andExpect(jsonPath("$.page.number", is(0)))
//The array of browse index should have a size 5
.andExpect(jsonPath("$._embedded.browses", hasSize(5)))
//The array of browse index should match the size of the total number of browse indices configured
.andExpect(jsonPath("$._embedded.browses", hasSize(bis.length)))
//Check that all (and only) the default browse indexes are present
.andExpect(jsonPath("$._embedded.browses", containsInAnyOrder(
BrowseIndexMatcher.dateIssuedBrowseIndex("asc"),
BrowseIndexMatcher.contributorBrowseIndex("asc"),
BrowseIndexMatcher.titleBrowseIndex("asc"),
BrowseIndexMatcher.subjectBrowseIndex("asc"),
BrowseIndexMatcher.hierarchicalBrowseIndex("srsc")
)))
//Check that all (and only) the configured browse indexes are present
.andExpect(jsonPath("$._embedded.browses", containsInAnyOrder(browseMatchers)))
;
}

View File

@@ -9,7 +9,13 @@ package org.dspace.app.rest;
import static com.google.common.net.UrlEscapers.urlPathSegmentEscaper;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
import static org.dspace.app.rest.matcher.FacetEntryMatcher.defaultFacetMatchers;
import static org.dspace.app.rest.matcher.FacetEntryMatcher.supervisionFacetMatchers;
import static org.dspace.app.rest.matcher.FacetEntryMatcher.workflowAdminFacetMatchers;
import static org.dspace.app.rest.matcher.FacetEntryMatcher.workflowFacetMatchers;
import static org.dspace.app.rest.matcher.FacetEntryMatcher.workspaceFacetMatchers;
import static org.dspace.app.rest.matcher.FacetValueMatcher.entrySupervisedBy;
import static org.dspace.app.rest.matcher.SearchFilterMatcher.searchFilterMatchers;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -28,8 +34,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.io.InputStream;
import java.nio.charset.Charset;
import java.time.Period;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -43,7 +47,6 @@ import org.dspace.app.rest.matcher.FacetEntryMatcher;
import org.dspace.app.rest.matcher.FacetValueMatcher;
import org.dspace.app.rest.matcher.ItemMatcher;
import org.dspace.app.rest.matcher.PageMatcher;
import org.dspace.app.rest.matcher.SearchFilterMatcher;
import org.dspace.app.rest.matcher.SearchResultMatcher;
import org.dspace.app.rest.matcher.SortOptionMatcher;
import org.dspace.app.rest.matcher.WorkflowItemMatcher;
@@ -78,7 +81,6 @@ import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.supervision.SupervisionOrder;
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;
@@ -95,24 +97,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
@Autowired
ChoiceAuthorityService choiceAuthorityService;
/**
* This field has been created to easily modify the tests when updating the defaultConfiguration's sidebar facets
*/
List<Matcher<? super Object>> customSidebarFacets = List.of(
);
/**
* This field has been created to easily modify the tests when updating the defaultConfiguration's search filters
*/
List<Matcher<? super Object>> customSearchFilters = List.of(
);
/**
* This field has been created to easily modify the tests when updating the defaultConfiguration's sort fields
*/
List<Matcher<? super Object>> customSortFields = List.of(
);
@Test
public void rootDiscoverTest() throws Exception {
@@ -133,14 +117,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
@Test
public void discoverFacetsTestWithoutParameters() throws Exception {
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
//When we call this facets endpoint
getClient().perform(get("/api/discover/facets"))
@@ -152,7 +128,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//There needs to be a self link to this endpoint
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
//We have 4 facets in the default configuration, they need to all be present in the embedded section
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(allExpectedSidebarFacets)));
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(defaultFacetMatchers)));
}
@Test
@@ -920,8 +896,8 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
is(PageMatcher.pageEntry(0, 20))))
//The date values need to be as specified below
.andExpect(jsonPath("$._embedded.values", containsInAnyOrder(
//We'll always get at least two intervals with the items specified above, so we ask to match
// twice at least
//We'll always get atleast two intervals with the items specified above, so we ask to match
// twice atleast
FacetValueMatcher.entryDateIssued(),
FacetValueMatcher.entryDateIssued()
)))
@@ -1224,34 +1200,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
@Test
public void discoverSearchTest() throws Exception {
List<Matcher<? super Object>> allExpectedSearchFilters = new ArrayList<>(customSearchFilters);
allExpectedSearchFilters.addAll(List.of(
SearchFilterMatcher.titleFilter(),
SearchFilterMatcher.authorFilter(),
SearchFilterMatcher.subjectFilter(),
SearchFilterMatcher.dateIssuedFilter(),
SearchFilterMatcher.hasContentInOriginalBundleFilter(),
SearchFilterMatcher.hasFileNameInOriginalBundleFilter(),
SearchFilterMatcher.hasFileDescriptionInOriginalBundleFilter(),
SearchFilterMatcher.entityTypeFilter(),
SearchFilterMatcher.isAuthorOfPublicationRelation(),
SearchFilterMatcher.isProjectOfPublicationRelation(),
SearchFilterMatcher.isOrgUnitOfPublicationRelation(),
SearchFilterMatcher.isPublicationOfJournalIssueRelation(),
SearchFilterMatcher.isJournalOfPublicationRelation()
));
List<Matcher<? super Object>> allExpectedSortFields = new ArrayList<>(customSortFields);
allExpectedSortFields.addAll(List.of(
SortOptionMatcher.sortOptionMatcher(
"score", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()),
SortOptionMatcher.sortOptionMatcher(
"dc.title", DiscoverySortFieldConfiguration.SORT_ORDER.asc.name()),
SortOptionMatcher.sortOptionMatcher(
"dc.date.issued", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()),
SortOptionMatcher.sortOptionMatcher(
"dc.date.accessioned", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name())
));
//When calling this root endpoint
getClient().perform(get("/api/discover/search"))
@@ -1266,9 +1214,18 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/search")))
//There needs to be a section where these filters as specified as they're the default filters
// given in the configuration
.andExpect(jsonPath("$.filters", containsInAnyOrder(allExpectedSearchFilters)))
.andExpect(jsonPath("$.filters", containsInAnyOrder(searchFilterMatchers)))
//These sortOptions need to be present as it's the default in the configuration
.andExpect(jsonPath("$.sortOptions", contains(allExpectedSortFields)));
.andExpect(jsonPath("$.sortOptions", contains(
SortOptionMatcher.sortOptionMatcher(
"score", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()),
SortOptionMatcher.sortOptionMatcher(
"dc.title", DiscoverySortFieldConfiguration.SORT_ORDER.asc.name()),
SortOptionMatcher.sortOptionMatcher(
"dc.date.issued", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()),
SortOptionMatcher.sortOptionMatcher(
"dc.date.accessioned", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name())
)));
}
@Test
@@ -1372,14 +1329,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects"))
//** THEN **
//The status has to be 200 OK
@@ -1406,7 +1355,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -1510,14 +1459,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(true),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects"))
//** THEN **
//The status has to be 200 OK
@@ -1547,7 +1488,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
// property because we don't exceed their default limit for a hasMore true (the default is 10)
//We do however exceed the limit for the authors, so this property has to be true for the author
// facet
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -1603,15 +1544,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
context.restoreAuthSystemState();
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(true),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
//An anonymous user browses this endpoint to find the the objects in the system
getClient().perform(get("/api/discover/search/objects"))
//** THEN **
@@ -1639,7 +1572,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
// property because we don't exceed their default limit for a hasMore true (the default is 10)
//We do however exceed the limit for the subject, so this property has to be true for the subject
// facet
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -1688,14 +1621,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a query that says that the title has to contain 'test'
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "test,contains"))
@@ -1721,7 +1646,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -1796,14 +1721,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a scope 'test'
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("scope", "test"))
@@ -1831,7 +1748,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -1883,14 +1800,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
// An anonymous user browses this endpoint to find the objects in the system
// With dsoType 'item'
List<Matcher<? super Object>> allExpectedSidebarFacetsWithDsoTypeItem = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacetsWithDsoTypeItem.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("dsoType", "Item"))
@@ -1913,20 +1822,11 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets",
Matchers.containsInAnyOrder(allExpectedSidebarFacetsWithDsoTypeItem)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")));
// With dsoTypes 'community' and 'collection'
List<Matcher<? super Object>> allExpectedSidebarFacetsWithDsoTypesComCol = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacetsWithDsoTypesComCol.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("dsoType", "Community")
.param("dsoType", "Collection"))
@@ -1951,21 +1851,11 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets",
Matchers.containsInAnyOrder(allExpectedSidebarFacetsWithDsoTypesComCol)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")));
// With dsoTypes 'collection' and 'item'
List<Matcher<? super Object>> allExpectedSidebarFacetsWithDsoTypesColItem =
new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacetsWithDsoTypesColItem.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("dsoType", "Collection")
.param("dsoType", "Item"))
@@ -1991,21 +1881,11 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets",
Matchers.containsInAnyOrder(allExpectedSidebarFacetsWithDsoTypesColItem)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")));
// With dsoTypes 'community', 'collection' and 'item'
List<Matcher<? super Object>> allExpectedSidebarFacetsWithDsoTypesComColItem =
new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacetsWithDsoTypesComColItem.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("dsoType", "Community")
.param("dsoType", "Collection")
@@ -2035,8 +1915,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets",
Matchers.containsInAnyOrder(allExpectedSidebarFacetsWithDsoTypesComColItem)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")));
}
@@ -2086,14 +1965,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//An anonymous user browses this endpoint to find the objects in the system
//With a dsoType 'item'
//And a sort on the dc.title ascending
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("dsoType", "Item")
.param("sort", "dc.title,ASC"))
@@ -2125,7 +1996,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//We want to get the sort that's been used as well in the response
.andExpect(jsonPath("$.sort", is(
SortOptionMatcher.sortByAndOrder("dc.title", "ASC")
@@ -2309,14 +2180,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a size 2
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(true),
FacetEntryMatcher.subjectFacet(true),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false),
FacetEntryMatcher.entityTypeFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("size", "2")
.param("page", "1"))
@@ -2339,7 +2202,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
SearchResultMatcher.match(),
SearchResultMatcher.match()
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -2404,14 +2267,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a query stating 'ThisIsSomeDummyText'
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("query", "ThisIsSomeDummyText"))
@@ -2431,7 +2286,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -2484,15 +2339,8 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//Turn on the authorization again
context.restoreAuthSystemState();
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
//An anonymous user browses this endpoint to find the the objects in the system
//
getClient().perform(get("/api/discover/search/objects"))
//** THEN **
//The status has to be 200 OK
@@ -2522,7 +2370,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -2601,12 +2449,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -2659,14 +2502,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the scope given
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("scope", String.valueOf(scope)))
//** THEN **
@@ -2687,7 +2522,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -2740,14 +2575,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a size 2
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("scope", String.valueOf(scope)))
//** THEN **
@@ -2774,7 +2601,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
))))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -2931,14 +2758,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a query stating 'public'
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("query", query))
//** THEN **
@@ -2959,7 +2778,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3078,14 +2897,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "test*,query"))
//** THEN **
@@ -3104,7 +2915,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3155,14 +2966,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "test,contains"))
//** THEN **
@@ -3181,8 +2984,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3232,14 +3034,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "-test*,query"))
//** THEN **
@@ -3257,7 +3051,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3308,14 +3102,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "test,notcontains"))
//** THEN **
@@ -3333,8 +3119,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3391,15 +3176,8 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a size 2
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacetWithMinMax(true, "Doe, Jane", "Testing, Works"),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(true),
FacetEntryMatcher.dateIssuedFacetWithMinMax(false, "1990-02-13", "2010-10-17"),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("configuration" , "minAndMaxTests")
.param("size", "2")
.param("page", "1"))
//** THEN **
@@ -3421,7 +3199,13 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
SearchResultMatcher.match(),
SearchResultMatcher.match()
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.authorFacetWithMinMax("Doe, Jane", "Testing, Works"),
FacetEntryMatcher.entityTypeFacet(),
FacetEntryMatcher.subjectFacet(),
FacetEntryMatcher.dateIssuedFacetWithMinMax("1990-02-13", "2010-10-17"),
FacetEntryMatcher.hasContentInOriginalBundleFacet()
)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3478,21 +3262,20 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With a size 2
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacetWithMinMax(true, "Doe, Jane", "Testing, Works"),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(true),
FacetEntryMatcher.dateIssuedFacetWithMinMax(false, "1990-02-13", "2010-10-17"),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/facets"))
getClient().perform(get("/api/discover/search/facets")
.param("configuration", "minAndMaxTests"))
//** THEN **
//The status has to be 200 OK
.andExpect(status().isOk())
//The type has to be 'discover'
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.authorFacetWithMinMax("Doe, Jane", "Testing, Works"),
FacetEntryMatcher.entityTypeFacet(),
FacetEntryMatcher.subjectFacet(),
FacetEntryMatcher.dateIssuedFacetWithMinMax("1990-02-13", "2010-10-17"),
FacetEntryMatcher.hasContentInOriginalBundleFacet()
)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/facets")))
;
@@ -3542,14 +3325,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "Test,query"))
//** THEN **
@@ -3567,7 +3342,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3618,14 +3393,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "Test,equals"))
//** THEN **
@@ -3643,7 +3410,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3693,14 +3460,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "-Test,query"))
//** THEN **
@@ -3719,7 +3478,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3770,14 +3529,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "Test,notequals"))
//** THEN **
@@ -3796,7 +3547,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3846,14 +3597,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "-id:test,query"))
//** THEN **
@@ -3871,7 +3614,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -3922,14 +3665,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
//** WHEN **
//An anonymous user browses this endpoint to find the objects in the system
//With the given search filter
List<Matcher<? super Object>> allExpectedSidebarFacets = new ArrayList<>(customSidebarFacets);
allExpectedSidebarFacets.addAll(List.of(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.entityTypeFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false)
));
getClient().perform(get("/api/discover/search/objects")
.param("f.title", "test,notauthority"))
//** THEN **
@@ -3947,7 +3682,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore property
// because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link available
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -4396,7 +4131,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(allExpectedSidebarFacets)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(defaultFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -4546,11 +4281,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.resourceTypeFacet(false),
FacetEntryMatcher.typeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(workspaceFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -4592,11 +4323,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.resourceTypeFacet(false),
FacetEntryMatcher.typeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(workspaceFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -4776,12 +4503,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.resourceTypeFacet(false),
FacetEntryMatcher.typeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.submitterFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(workflowFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -4826,12 +4548,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.resourceTypeFacet(false),
FacetEntryMatcher.typeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.submitterFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(workflowFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -4859,12 +4576,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.resourceTypeFacet(false),
FacetEntryMatcher.typeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.submitterFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(workflowFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -5073,12 +4785,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
// property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.resourceTypeFacet(false),
FacetEntryMatcher.typeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.submitterFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(workflowAdminFacetMatchers)))
//There always needs to be a self link
.andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects")))
;
@@ -6847,13 +6554,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
)))
//These facets have to show up in the embedded.facets section as well with the given hasMore
//property because we don't exceed their default limit for a hasMore true (the default is 10)
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(
FacetEntryMatcher.resourceTypeFacet(false),
FacetEntryMatcher.typeFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.submitterFacet(false),
FacetEntryMatcher.supervisedByFacet(false)
)))
.andExpect(jsonPath("$._embedded.facets", Matchers.containsInAnyOrder(supervisionFacetMatchers)))
//check supervisedBy Facet values
.andExpect(jsonPath("$._embedded.facets[4]._embedded.values",
contains(

View File

@@ -7,6 +7,7 @@
*/
package org.dspace.app.rest;
import static org.dspace.app.rest.matcher.FacetEntryMatcher.defaultFacetMatchers;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
@@ -277,8 +278,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "parentcommunity1field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("parentcommunity1field", "text")))
);
getClient().perform(get("/api/discover/facets/parentcommunity1field")
@@ -318,8 +319,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "subcommunity11field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("subcommunity11field", "text")))
);
getClient().perform(get("/api/discover/facets/subcommunity11field")
@@ -350,8 +351,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "collection111field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("collection111field", "text")))
);
getClient().perform(get("/api/discover/facets/collection111field")
@@ -381,8 +382,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "subcommunity11field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("subcommunity11field", "text")))
);
getClient().perform(get("/api/discover/facets/subcommunity11field")
@@ -410,8 +411,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "parentcommunity1field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("parentcommunity1field", "text")))
);
getClient().perform(get("/api/discover/facets/parentcommunity1field")
@@ -442,8 +443,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "collection121field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("collection121field", "text")))
);
getClient().perform(get("/api/discover/facets/collection121field")
@@ -471,8 +472,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "parentcommunity1field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("parentcommunity1field", "text")))
);
getClient().perform(get("/api/discover/facets/parentcommunity1field")
@@ -501,13 +502,7 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(status().isOk())
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false),
FacetEntryMatcher.entityTypeFacet(false)
))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(defaultFacetMatchers))
);
}
@@ -523,8 +518,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "subcommunity21field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("subcommunity21field", "text")))
);
getClient().perform(get("/api/discover/facets/subcommunity21field")
@@ -555,8 +550,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "collection211field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("collection211field", "text")))
);
getClient().perform(get("/api/discover/facets/collection211field")
@@ -586,8 +581,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "subcommunity21field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("subcommunity21field", "text")))
);
getClient().perform(get("/api/discover/facets/subcommunity21field")
@@ -613,13 +608,7 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(status().isOk())
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false),
FacetEntryMatcher.entityTypeFacet(false)
))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(defaultFacetMatchers))
);
}
@@ -635,8 +624,8 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.matchFacet(false, "collection221field", "text")))
FacetEntryMatcher.authorFacet(),
FacetEntryMatcher.matchFacet("collection221field", "text")))
);
getClient().perform(get("/api/discover/facets/collection221field")
@@ -663,13 +652,7 @@ public class DiscoveryScopeBasedRestControllerIT extends AbstractControllerInteg
.andExpect(status().isOk())
.andExpect(jsonPath("$.type", is("discover")))
.andExpect(jsonPath("$._links.self.href", containsString("api/discover/facets")))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(
FacetEntryMatcher.authorFacet(false),
FacetEntryMatcher.subjectFacet(false),
FacetEntryMatcher.dateIssuedFacet(false),
FacetEntryMatcher.hasContentInOriginalBundleFacet(false),
FacetEntryMatcher.entityTypeFacet(false)
))
.andExpect(jsonPath("$._embedded.facets", containsInAnyOrder(defaultFacetMatchers))
);
}

View File

@@ -18,6 +18,17 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.dspace.browse.BrowseException;
import org.dspace.browse.BrowseIndex;
import org.dspace.content.authority.DSpaceControlledVocabularyIndex;
import org.dspace.content.authority.factory.ContentAuthorityServiceFactory;
import org.dspace.content.authority.service.ChoiceAuthorityService;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.hamcrest.Matcher;
/**
@@ -28,8 +39,114 @@ import org.hamcrest.Matcher;
*/
public class BrowseIndexMatcher {
static ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
static ChoiceAuthorityService choiceAuthorityService =
ContentAuthorityServiceFactory.getInstance().getChoiceAuthorityService();
public static BrowseIndex[] bis = getAllBrowseIndices();
public static Matcher<? super Object>[] browseMatchers = createBrowseMatchers(List.of(bis));
private BrowseIndexMatcher() { }
private static BrowseIndex[] getAllBrowseIndices() {
List<BrowseIndex> browseIndices = new ArrayList<>();
browseIndices.addAll(List.of(getConfiguredBrowseIndices()));
browseIndices.addAll(getVocabularyIndices());
return browseIndices.toArray(new BrowseIndex[0]);
}
private static BrowseIndex[] getConfiguredBrowseIndices() {
try {
return BrowseIndex.getBrowseIndices();
} catch (BrowseException e) {
throw new RuntimeException(e);
}
}
private static List<DSpaceControlledVocabularyIndex> getVocabularyIndices() {
// Get all names of vocabularies in the project (configured in /dspace/config/controlled-vocabularies/)
File vocDir = new File(configurationService.getProperty("dspace.dir") + "/config/controlled-vocabularies");
// And store them in a list
List<DSpaceControlledVocabularyIndex> vocabularies = new ArrayList<>();
for (File file : vocDir.listFiles()) {
if (file.isFile() && file.getName().endsWith(".xml")) {
String vocName = file.getName().substring(0, file.getName().lastIndexOf('.'));
// Get the vocabulary index, if not null add to the list
DSpaceControlledVocabularyIndex vocBrowseIndex = choiceAuthorityService.getVocabularyIndex(vocName);
if (vocBrowseIndex != null) {
vocabularies.add(vocBrowseIndex);
}
}
}
return vocabularies;
}
public static Matcher<? super Object>[] createBrowseMatchers(List<BrowseIndex> browseIndices) {
return browseIndices.stream()
.map(BrowseIndexMatcher::matchBrowseIndex)
.toArray(Matcher[]::new);
}
public static Matcher<? super Object> matchBrowseIndex(BrowseIndex bi) {
if (bi instanceof DSpaceControlledVocabularyIndex) {
DSpaceControlledVocabularyIndex vocbi = (DSpaceControlledVocabularyIndex) bi;
return allOf(
hasJsonPath("$.metadata", contains(getIndexMetadata(vocbi))),
hasJsonPath("$.browseType", equalToIgnoringCase(BROWSE_TYPE_HIERARCHICAL)),
hasJsonPath("$.type", equalToIgnoringCase("browse")),
hasJsonPath("$.facetType", equalToIgnoringCase(vocbi.getFacetConfig().getIndexFieldName())),
hasJsonPath("$.vocabulary", equalToIgnoringCase(vocbi.getVocabulary().getPluginInstanceName())),
hasJsonPath("$._links.vocabulary.href",
is(REST_SERVER_URL + String.format("submission/vocabularies/%s/",
vocbi.getVocabulary().getPluginInstanceName()))),
hasJsonPath("$._links.items.href",
is(REST_SERVER_URL + String.format("discover/browses/%s/items",
vocbi.getVocabulary().getPluginInstanceName()))),
hasJsonPath("$._links.entries.href",
is(REST_SERVER_URL + String.format("discover/browses/%s/entries",
vocbi.getVocabulary().getPluginInstanceName()))),
hasJsonPath("$._links.self.href",
is(REST_SERVER_URL + String.format("discover/browses/%s",
vocbi.getVocabulary().getPluginInstanceName())))
);
} else {
return allOf(
hasJsonPath("$.metadata", contains(getIndexMetadata(bi))),
hasJsonPath("$.browseType", equalToIgnoringCase(getBrowseType(bi))),
hasJsonPath("$.type", equalToIgnoringCase("browse")),
hasJsonPath("$.dataType", equalToIgnoringCase(bi.getDataType())),
hasJsonPath("$.order", equalToIgnoringCase(bi.getDefaultOrder())),
hasJsonPath("$.sortOptions[*].name", containsInAnyOrder("title", "dateissued", "dateaccessioned")),
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "discover/browses/" + bi.getName())),
hasJsonPath("$._links.entries.href", is(REST_SERVER_URL + "discover/browses/"
+ bi.getName() + "/entries")),
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "discover/browses/"
+ bi.getName() + "/items"))
);
}
}
private static String[] getIndexMetadata(BrowseIndex bi) {
if (bi instanceof DSpaceControlledVocabularyIndex) {
DSpaceControlledVocabularyIndex vocObj = (DSpaceControlledVocabularyIndex) bi;
return vocObj.getMetadataFields().toArray(new String[0]);
} else if (bi.isMetadataIndex()) {
return bi.getMetadata().split(",");
} else {
return new String[]{bi.getSortOption().getMetadata()};
}
}
private static String getBrowseType(BrowseIndex bi) {
if (bi.isMetadataIndex()) {
return BROWSE_TYPE_VALUE_LIST;
} else {
return BROWSE_TYPE_FLAT;
}
}
public static Matcher<? super Object> subjectBrowseIndex(final String order) {
return allOf(
hasJsonPath("$.metadata", contains("dc.subject.*")),

View File

@@ -15,6 +15,11 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import java.util.List;
import org.dspace.discovery.configuration.DiscoveryConfiguration;
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.hamcrest.Matcher;
import org.hamcrest.core.AnyOf;
@@ -23,17 +28,55 @@ public class FacetEntryMatcher {
private FacetEntryMatcher() {
}
public static Matcher<? super Object> authorFacet(boolean hasNext) {
// List of facet matches for discovery configurations
// Add more configurations if needed for further tests here
public static Matcher<? super Object>[] defaultFacetMatchers =
getFacetMatchersForConfig("defaultConfiguration");
public static Matcher<? super Object>[] workflowFacetMatchers =
getFacetMatchersForConfig("workflowConfiguration");
public static Matcher<? super Object>[] workspaceFacetMatchers =
getFacetMatchersForConfig("workspaceConfiguration");
public static Matcher<? super Object>[] supervisionFacetMatchers =
getFacetMatchersForConfig("supervisionConfiguration");
public static Matcher<? super Object>[] workflowAdminFacetMatchers =
getFacetMatchersForConfig("workflowAdminConfiguration");
public static Matcher<? super Object>[] getFacetMatchersForConfig(String configName) {
DiscoveryConfiguration config =
DSpaceServicesFactory.getInstance()
.getServiceManager()
.getServiceByName(configName, DiscoveryConfiguration.class);
List<DiscoverySearchFilterFacet> sidebarFacets = config.getSidebarFacets();
return createFacetMatchers(sidebarFacets);
}
public static Matcher<? super Object> matchFacet(DiscoverySearchFilterFacet facet) {
return allOf(
hasJsonPath("$.name", is(facet.getIndexFieldName())),
hasJsonPath("$.facetType", is(facet.getType())),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/" + facet.getIndexFieldName())),
hasJsonPath("$._links", matchNextLink("api/discover/facets/" + facet.getIndexFieldName()))
);
}
public static Matcher<? super Object>[] createFacetMatchers(List<DiscoverySearchFilterFacet> facets) {
return facets.stream()
.map(FacetEntryMatcher::matchFacet)
.toArray(Matcher[]::new);
}
public static Matcher<? super Object> authorFacet() {
return allOf(
hasJsonPath("$.name", is("author")),
hasJsonPath("$.facetType", is("text")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/author")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/author"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/author"))
);
}
public static Matcher<? super Object> authorFacetWithMinMax(boolean hasNext, String min, String max) {
public static Matcher<? super Object> authorFacetWithMinMax(String min, String max) {
return allOf(
hasJsonPath("$.name", is("author")),
hasJsonPath("$.facetType", is("text")),
@@ -41,54 +84,54 @@ public class FacetEntryMatcher {
hasJsonPath("$.minValue", is(min)),
hasJsonPath("$.maxValue", is(max)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/author")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/author"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/author"))
);
}
public static Matcher<? super Object> subjectFacet(boolean hasNext) {
public static Matcher<? super Object> subjectFacet() {
return allOf(
hasJsonPath("$.name", is("subject")),
hasJsonPath("$.facetType", is("hierarchical")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/subject")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/subject"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/subject"))
);
}
public static Matcher<? super Object> submitterFacet(boolean hasNext) {
public static Matcher<? super Object> submitterFacet() {
return allOf(
hasJsonPath("$.name", is("submitter")),
hasJsonPath("$.facetType", is("authority")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/submitter")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/submitter"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/submitter"))
);
}
public static Matcher<? super Object> supervisedByFacet(boolean hasNext) {
public static Matcher<? super Object> supervisedByFacet() {
return allOf(
hasJsonPath("$.name", is("supervisedBy")),
hasJsonPath("$.facetType", is("authority")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/supervisedBy")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/supervisedBy"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/supervisedBy"))
);
}
public static Matcher<? super Object> dateIssuedFacet(boolean hasNext) {
public static Matcher<? super Object> dateIssuedFacet() {
return allOf(
hasJsonPath("$.name", is("dateIssued")),
hasJsonPath("$.facetType", is("date")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/dateIssued")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/dateIssued"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/dateIssued"))
);
}
public static Matcher<? super Object> dateIssuedFacetWithMinMax(boolean hasNext, String min, String max) {
public static Matcher<? super Object> dateIssuedFacetWithMinMax(String min, String max) {
return allOf(
hasJsonPath("$.name", is("dateIssued")),
hasJsonPath("$.facetType", is("date")),
@@ -96,77 +139,73 @@ public class FacetEntryMatcher {
hasJsonPath("$.minValue", is(min)),
hasJsonPath("$.maxValue", is(max)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/dateIssued")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/dateIssued"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/dateIssued"))
);
}
public static Matcher<? super Object> hasContentInOriginalBundleFacet(boolean hasNext) {
public static Matcher<? super Object> hasContentInOriginalBundleFacet() {
return allOf(
hasJsonPath("$.name", is("has_content_in_original_bundle")),
hasJsonPath("$.facetType", is("standard")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/has_content_in_original_bundle")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/has_content_in_original_bundle"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/has_content_in_original_bundle"))
);
}
public static Matcher<? super Object> matchFacet(boolean hasNext, String name, String facetType) {
public static Matcher<? super Object> matchFacet(String name, String facetType) {
return allOf(
hasJsonPath("$.name", is(name)),
hasJsonPath("$.facetType", is(facetType)),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/" + name)),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/" + name))
hasJsonPath("$._links", matchNextLink("api/discover/facets/" + name))
);
}
/**
* Check that a facet over the dc.type exists and match the default configuration
*
* @param b
* true if we expect more values
*
* @return a Matcher
*/
public static Matcher<? super Object> typeFacet(boolean b) {
public static Matcher<? super Object> typeFacet() {
return allOf(
hasJsonPath("$.name", is("itemtype")),
hasJsonPath("$.facetType", is("text")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/itemtype")),
hasJsonPath("$._links", matchNextLink(b, "api/discover/facets/itemtype"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/itemtype"))
);
}
/**
* Check that a facet over the object type (workspaceitem, workflowitem, etc.) exists and match the default
* configuration
*
* @param b
* true if we expect more values
*
* @return a Matcher
*/
public static Matcher<? super Object> resourceTypeFacet(boolean b) {
public static Matcher<? super Object> resourceTypeFacet() {
return allOf(
hasJsonPath("$.name", is("namedresourcetype")),
hasJsonPath("$.facetType", is("authority")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/namedresourcetype")),
hasJsonPath("$._links", matchNextLink(b, "api/discover/facets/namedresourcetype"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/namedresourcetype"))
);
}
private static AnyOf<? super Object> matchNextLink(boolean hasNext, String path) {
private static AnyOf<? super Object> matchNextLink(String path) {
return anyOf(hasJsonPath("$.next.href", containsString(path)),
not(hasJsonPath("$.next.href", containsString(path))));
}
public static Matcher<? super Object> entityTypeFacet(boolean hasNext) {
public static Matcher<? super Object> entityTypeFacet() {
return allOf(
hasJsonPath("$.name", is("entityType")),
hasJsonPath("$.facetLimit", any(Integer.class)),
hasJsonPath("$._links.self.href", containsString("api/discover/facets/entityType")),
hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/entityType"))
hasJsonPath("$._links", matchNextLink("api/discover/facets/entityType"))
);
}

View File

@@ -12,81 +12,44 @@ import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import java.util.List;
import org.dspace.discovery.configuration.DiscoveryConfiguration;
import org.dspace.discovery.configuration.DiscoverySearchFilter;
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.hamcrest.Matcher;
public class SearchFilterMatcher {
private SearchFilterMatcher() { }
public static Matcher<? super Object> titleFilter() {
return allOf(
hasJsonPath("$.filter", is("title")),
hasJsonPath("$.hasFacets", is(false)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(true)),
checkOperators()
public static final DiscoveryConfiguration defaultConfig =
DSpaceServicesFactory.getInstance()
.getServiceManager()
.getServiceByName("defaultConfiguration", DiscoveryConfiguration.class);
public static final List<DiscoverySearchFilterFacet> sidebarFacets = defaultConfig.getSidebarFacets();
public static final List<DiscoverySearchFilter> searchFilters = defaultConfig.getSearchFilters();
public static final Matcher<? super Object>[] searchFilterMatchers = createSearchFilterMatchers(searchFilters);
public static Matcher<? super Object> matchSearchFilter(DiscoverySearchFilter searchFilter) {
return allOf(
hasJsonPath("$.filter", is(searchFilter.getIndexFieldName())),
hasJsonPath("$.hasFacets", is(isFacet(searchFilter))),
hasJsonPath("$.type", is(searchFilter.getType())),
hasJsonPath("$.openByDefault", is(searchFilter.isOpenByDefault())),
checkOperators()
);
}
public static Matcher<? super Object> authorFilter() {
return allOf(
hasJsonPath("$.filter", is("author")),
hasJsonPath("$.hasFacets", is(true)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(true)),
checkOperators()
);
public static Matcher<? super Object>[] createSearchFilterMatchers(List<DiscoverySearchFilter> searchFilters) {
return searchFilters.stream()
.map(SearchFilterMatcher::matchSearchFilter)
.toArray(Matcher[]::new);
}
public static Matcher<? super Object> subjectFilter() {
return allOf(
hasJsonPath("$.filter", is("subject")),
hasJsonPath("$.hasFacets", is(true)),
hasJsonPath("$.type", is("hierarchical")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> dateIssuedFilter() {
return allOf(
hasJsonPath("$.filter", is("dateIssued")),
hasJsonPath("$.hasFacets", is(true)),
hasJsonPath("$.type", is("date")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> hasContentInOriginalBundleFilter() {
return allOf(
hasJsonPath("$.filter", is("has_content_in_original_bundle")),
hasJsonPath("$.hasFacets", is(true)),
hasJsonPath("$.type", is("standard")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> hasFileNameInOriginalBundleFilter() {
return allOf(
hasJsonPath("$.filter", is("original_bundle_filenames")),
checkOperators()
);
}
public static Matcher<? super Object> hasFileDescriptionInOriginalBundleFilter() {
return allOf(
hasJsonPath("$.filter", is("original_bundle_descriptions")),
checkOperators()
);
public static boolean isFacet(DiscoverySearchFilter sf) {
return sidebarFacets.stream().anyMatch(f -> f.equals(sf));
}
public static Matcher<? super Object> checkOperators() {
@@ -102,58 +65,4 @@ public class SearchFilterMatcher {
))
);
}
public static Matcher<? super Object> entityTypeFilter() {
return allOf(
hasJsonPath("$.filter", is("entityType")),
hasJsonPath("$.hasFacets", is(true)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> isAuthorOfPublicationRelation() {
return allOf(
hasJsonPath("$.filter", is("isAuthorOfPublication")),
hasJsonPath("$.hasFacets", is(false)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> isProjectOfPublicationRelation() {
return allOf(
hasJsonPath("$.filter", is("isProjectOfPublication")),
hasJsonPath("$.hasFacets", is(false)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> isOrgUnitOfPublicationRelation() {
return allOf(
hasJsonPath("$.filter", is("isOrgUnitOfPublication")),
hasJsonPath("$.hasFacets", is(false)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> isPublicationOfJournalIssueRelation() {
return allOf(
hasJsonPath("$.filter", is("isPublicationOfJournalIssue")),
hasJsonPath("$.hasFacets", is(false)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
public static Matcher<? super Object> isJournalOfPublicationRelation() {
return allOf(
hasJsonPath("$.filter", is("isJournalOfPublication")),
hasJsonPath("$.hasFacets", is(false)),
hasJsonPath("$.type", is("text")),
hasJsonPath("$.openByDefault", is(false)),
checkOperators()
);
}
}