Skip to content

Commit bad9532

Browse files
authored
VSB-TUO/leaving property webui.browse.vocabularies.disabled empty for test (#1202)
* leaving property webui.browse.vocabularies.disabled empty * added srsc to property for test findAll * set 6 to 5 size * set test back to original, set size from 6 to 5 * set back size from 5 to 6 * use 6 element instead of 5 because of the config * added proeprty * fix checkstyle
1 parent 8a5c48c commit bad9532

2 files changed

Lines changed: 42 additions & 22 deletions

File tree

dspace-api/src/test/data/dspaceFolder/config/local.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,6 @@ info.app.name = DSpace at My University
383383
# SubmissionFormsControllerIT.java#userChoiceAnotherLanguageTest
384384
# SubmissionFormsControllerIT.java#defaultLanguageTest
385385
choices.plugin.dc.contributor.author =
386+
387+
# Leaving this property empty (as below) means all vocabularies, including 'srsc', are enabled for browsing.
388+
webui.browse.vocabularies.disabled =

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

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,49 @@ public class BrowsesResourceControllerIT extends AbstractControllerIntegrationTe
5858

5959
@Test
6060
public void findAll() throws Exception {
61-
//When we call the root endpoint
61+
// Save the original configuration value
62+
String[] originalValue = configurationService.getArrayProperty("webui.browse.vocabularies.disabled");
63+
try {
64+
// Override the configuration specifically for this test to use 'srsc'
65+
configurationService.setProperty("webui.browse.vocabularies.disabled", "srsc");
66+
// Clear cache to ensure the configuration change takes effect
67+
metadataAuthorityService.clearCache();
68+
//When we call the root endpoint
6269
getClient().perform(get("/api/discover/browses"))
63-
//The status has to be 200 OK
64-
.andExpect(status().isOk())
65-
//We expect the content type to be "application/hal+json;charset=UTF-8"
66-
.andExpect(content().contentType(contentType))
70+
//The status has to be 200 OK
71+
.andExpect(status().isOk())
72+
//We expect the content type to be "application/hal+json;charset=UTF-8"
73+
.andExpect(content().contentType(contentType))
6774

68-
//Our default Discovery config has 6 browse indexes, so we expect this to be reflected in the page
69-
// object
70-
.andExpect(jsonPath("$.page.size", is(20)))
71-
.andExpect(jsonPath("$.page.totalElements", is(5)))
72-
.andExpect(jsonPath("$.page.totalPages", is(1)))
73-
.andExpect(jsonPath("$.page.number", is(0)))
75+
//Our default Discovery config has 6 browse indexes, so we expect this to be reflected in the page
76+
// object
77+
.andExpect(jsonPath("$.page.size", is(20)))
78+
.andExpect(jsonPath("$.page.totalElements", is(5)))
79+
.andExpect(jsonPath("$.page.totalPages", is(1)))
80+
.andExpect(jsonPath("$.page.number", is(0)))
7481

75-
//The array of browse index should have a size 6
76-
.andExpect(jsonPath("$._embedded.browses", hasSize(6)))
77-
78-
//Check that all (and only) the default browse indexes are present
79-
.andExpect(jsonPath("$._embedded.browses", containsInAnyOrder(
80-
BrowseIndexMatcher.dateIssuedBrowseIndex("asc"),
81-
BrowseIndexMatcher.contributorBrowseIndex("asc"),
82-
BrowseIndexMatcher.titleBrowseIndex("asc"),
83-
BrowseIndexMatcher.subjectBrowseIndex("asc"),
84-
BrowseIndexMatcher.languageBrowseIndex("asc")
85-
)))
82+
//The array of browse index should have a size 6
83+
.andExpect(jsonPath("$._embedded.browses", hasSize(5)))
84+
85+
//Check that all (and only) the default browse indexes are present
86+
.andExpect(jsonPath("$._embedded.browses", containsInAnyOrder(
87+
BrowseIndexMatcher.dateIssuedBrowseIndex("asc"),
88+
BrowseIndexMatcher.contributorBrowseIndex("asc"),
89+
BrowseIndexMatcher.titleBrowseIndex("asc"),
90+
BrowseIndexMatcher.subjectBrowseIndex("asc"),
91+
BrowseIndexMatcher.languageBrowseIndex("asc")
92+
)))
8693
;
94+
} finally {
95+
// Restore the original configuration value
96+
if (originalValue != null) {
97+
configurationService.setProperty("webui.browse.vocabularies.disabled", originalValue);
98+
} else {
99+
configurationService.setProperty("webui.browse.vocabularies.disabled", (String) null);
100+
}
101+
// Clear cache to ensure the original configuration is restored
102+
metadataAuthorityService.clearCache();
103+
}
87104
}
88105

89106
@Test

0 commit comments

Comments
 (0)