Skip to content

Commit 6169f68

Browse files
milanmajchrakclaude
andcommitted
test(discovery): cover the /discover/search self link in the IT that actually runs
The upstream patch adds discoverSearchSelfLinkKeepsScopeAndConfigurationTest to DiscoveryRestControllerIT, but that class is @ignore'd at class level on dtq-dev (since eb40d60, unrelated facet-configuration failures), so the test would never execute here. - DiscoveryRestControllerIT: add the upstream test verbatim, at the same spot, so the file stays in step with upstream and future rebases stay clean. The class-level @ignore is left alone; lifting it is a separate job. - ClarinDiscoveryRestControllerIT: mirror the same test, in this file's continuation-indent style. This is the fork's live copy of the discovery ITs and it runs in CI, so this is where the fix is actually verified. The test asserts only on $._links.self.href, so it is independent of the fork's discovery.xml facet/sort customisations. Fixes dataquest-dev/dspace-customers#934 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 1fe20a7 commit 6169f68

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinDiscoveryRestControllerIT.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,33 @@ public void discoverSearchTest() throws Exception {
10211021
)));
10221022
}
10231023

1024+
@Test
1025+
public void discoverSearchSelfLinkKeepsScopeAndConfigurationTest() throws Exception {
1026+
context.turnOffAuthorisationSystem();
1027+
1028+
parentCommunity = CommunityBuilder.createCommunity(context)
1029+
.withName("Parent Community")
1030+
.build();
1031+
1032+
context.restoreAuthSystemState();
1033+
1034+
//The self link has to describe the request it answers
1035+
getClient().perform(get("/api/discover/search")
1036+
.param("scope", parentCommunity.getID().toString())
1037+
.param("configuration", "personOrOrgunit"))
1038+
.andExpect(status().isOk())
1039+
.andExpect(jsonPath("$._links.self.href",
1040+
containsString("scope=" + parentCommunity.getID())))
1041+
.andExpect(jsonPath("$._links.self.href",
1042+
containsString("configuration=personOrOrgunit")));
1043+
1044+
//And it may not add parameters the request did not have
1045+
getClient().perform(get("/api/discover/search"))
1046+
.andExpect(status().isOk())
1047+
.andExpect(jsonPath("$._links.self.href", not(containsString("scope="))))
1048+
.andExpect(jsonPath("$._links.self.href", not(containsString("configuration="))));
1049+
}
1050+
10241051
@Test
10251052
public void checkSortOrderInPersonOrOrgunitConfigurationTest() throws Exception {
10261053
getClient().perform(get("/api/discover/search")

dspace-server-webapp/src/test/java/org/dspace/app/rest/DiscoveryRestControllerIT.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,33 @@ public void discoverSearchTest() throws Exception {
12651265
.andExpect(jsonPath("$.sortOptions", contains(allExpectedSortFields)));
12661266
}
12671267

1268+
@Test
1269+
public void discoverSearchSelfLinkKeepsScopeAndConfigurationTest() throws Exception {
1270+
context.turnOffAuthorisationSystem();
1271+
1272+
parentCommunity = CommunityBuilder.createCommunity(context)
1273+
.withName("Parent Community")
1274+
.build();
1275+
1276+
context.restoreAuthSystemState();
1277+
1278+
//The self link has to describe the request it answers
1279+
getClient().perform(get("/api/discover/search")
1280+
.param("scope", parentCommunity.getID().toString())
1281+
.param("configuration", "personOrOrgunit"))
1282+
.andExpect(status().isOk())
1283+
.andExpect(jsonPath("$._links.self.href",
1284+
containsString("scope=" + parentCommunity.getID())))
1285+
.andExpect(jsonPath("$._links.self.href",
1286+
containsString("configuration=personOrOrgunit")));
1287+
1288+
//And it may not add parameters the request did not have
1289+
getClient().perform(get("/api/discover/search"))
1290+
.andExpect(status().isOk())
1291+
.andExpect(jsonPath("$._links.self.href", not(containsString("scope="))))
1292+
.andExpect(jsonPath("$._links.self.href", not(containsString("configuration="))));
1293+
}
1294+
12681295
@Test
12691296
public void checkSortOrderInPersonOrOrgunitConfigurationTest() throws Exception {
12701297
getClient().perform(get("/api/discover/search")

0 commit comments

Comments
 (0)