Skip to content

Commit

Permalink
105866: test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Atmire-Kristof committed Apr 29, 2024
1 parent 9d12600 commit d139d06
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
import com.nimbusds.jwt.util.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.dspace.core.Context;
import org.dspace.eperson.EPerson;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5822,10 +5822,6 @@ public void discoverSearchPoolTaskObjectsTest() throws Exception {
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects", Matchers.contains(
SearchResultMatcher.match("workflow", "pooltask", "pooltasks")
)))
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects",Matchers.contains(
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Mathematical Theory"))))
)))
.andExpect(jsonPath("$._embedded.searchResult.page.totalElements", is(1)));

getClient(adminToken).perform(get("/api/discover/search/objects")
Expand All @@ -5839,12 +5835,6 @@ public void discoverSearchPoolTaskObjectsTest() throws Exception {
SearchResultMatcher.match("workflow", "pooltask", "pooltasks"),
SearchResultMatcher.match("workflow", "pooltask", "pooltasks")
)))
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects",Matchers.containsInAnyOrder(
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Metaphysics")))),
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Test Metaphysics"))))
)))
.andExpect(jsonPath("$._embedded.searchResult.page.totalElements", is(2)));
}

Expand Down Expand Up @@ -5909,14 +5899,6 @@ public void discoverSearchPoolTaskObjectsEmptyQueryTest() throws Exception {
SearchResultMatcher.match("workflow", "pooltask", "pooltasks"),
SearchResultMatcher.match("workflow", "pooltask", "pooltasks")
)))
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects",Matchers.containsInAnyOrder(
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Mathematical Theory")))),
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Metaphysics")))),
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Test Metaphysics"))))
)))
.andExpect(jsonPath("$._embedded.searchResult.page.totalElements", is(3)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public void createEmptyWorkspaceItemLoginOnBehalfOfCheckSubmitterTest() throws E
// create a workspaceitem explicitly in the col1
MvcResult mvcResult = getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("owningCollection", col1.getID().toString())
.param("embed", "collection")
.header("X-On-Behalf-Of", eperson.getID())
.contentType(org.springframework
.http.MediaType.APPLICATION_JSON))
Expand All @@ -204,7 +205,8 @@ public void createEmptyWorkspaceItemLoginOnBehalfOfCheckSubmitterTest() throws E
Map<String,Object> map = mapper.readValue(content, Map.class);
String workspaceItemId = String.valueOf(map.get("id"));

getClient(authToken).perform(get("/api/submission/workspaceitems/" + workspaceItemId))
getClient(authToken).perform(get("/api/submission/workspaceitems/" + workspaceItemId)
.param("embed", "submitter"))
.andExpect(jsonPath("$._embedded.submitter", EPersonMatcher.matchProperties(eperson)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ public void createEmptyWorkspateItemTest() throws Exception {
// create a workspaceitem explicitly in the col1
getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("owningCollection", col1.getID().toString())
.param("embed", "collection")
.contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(status().isCreated())
.andExpect(jsonPath("$._embedded.collection.id", is(col1.getID().toString())))
Expand All @@ -886,6 +887,7 @@ public void createEmptyWorkspateItemTest() throws Exception {
// create a workspaceitem explicitly in the col2
getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("owningCollection", col2.getID().toString())
.param("embed", "collection")
.contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(status().isCreated())
.andExpect(jsonPath("$._embedded.collection.id", is(col2.getID().toString())))
Expand All @@ -894,10 +896,10 @@ public void createEmptyWorkspateItemTest() throws Exception {
// create a workspaceitem without an explicit collection, this will go in the first valid collection for the
// user: the col1
getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("embed", "collection")
.contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(status().isCreated())
.andExpect(jsonPath("$._embedded.collection.id", is(col1.getID().toString())))
.andExpect(jsonPath("$", WorkspaceItemMatcher.matchFullEmbeds()))
.andDo(result -> idRef3.set(read(result.getResponse().getContentAsString(), "$.id")));


Expand Down Expand Up @@ -945,7 +947,8 @@ public void createSingleWorkspaceItemFromBibtexFileWithOneEntryTest() throws Exc
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -974,6 +977,7 @@ public void createSingleWorkspaceItemFromBibtexFileWithOneEntryTest() throws Exc
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1037,7 +1041,8 @@ public void createSingleWorkspaceItemFromBibtexArticleFileWithOneEntryTest() thr
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
Expand Down Expand Up @@ -1071,6 +1076,7 @@ public void createSingleWorkspaceItemFromBibtexArticleFileWithOneEntryTest() thr
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
Expand Down Expand Up @@ -1134,7 +1140,8 @@ public void createSingleWorkspaceItemFromBibtexFileWithDiacriticsTest() throws E
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections." +
Expand Down Expand Up @@ -1165,6 +1172,7 @@ public void createSingleWorkspaceItemFromBibtexFileWithDiacriticsTest() throws E
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections." +
Expand Down Expand Up @@ -1231,7 +1239,8 @@ public void createSingleWorkspaceItemFromBibtexFileWithMultipleAuthorsTest() thr
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
Expand Down Expand Up @@ -1271,6 +1280,7 @@ public void createSingleWorkspaceItemFromBibtexFileWithMultipleAuthorsTest() thr
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
Expand Down Expand Up @@ -1336,7 +1346,8 @@ public void createSingleWorkspaceItemFromCSVWithOneEntryTest() throws Exception
AtomicReference<List<Integer>> idRef = new AtomicReference<>();
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile))
.file(csvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1376,6 +1387,7 @@ public void createSingleWorkspaceItemFromCSVWithOneEntryTest() throws Exception
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone"
Expand Down Expand Up @@ -1453,7 +1465,8 @@ public void createSingleWorkspaceItemFromCSVWithOneEntryAndMissingDataTest() thr

try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile))
.file(csvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1531,7 +1544,8 @@ public void createSingleWorkspaceItemFromTSVWithOneEntryTest() throws Exception
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(tsvFile))
.file(tsvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1607,7 +1621,8 @@ public void createSingleWorkspaceItemFromRISWithOneEntryTest() throws Exception
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(tsvFile))
.file(tsvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1684,7 +1699,8 @@ public void createSingleWorkspaceItemFromEndnoteWithOneEntryTest() throws Except
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(endnoteFile))
.file(endnoteFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1763,7 +1779,8 @@ public void createSingleWorkspaceItemFromTSVWithOneEntryAndMissingDataTest() thr
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile))
.file(csvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1844,7 +1861,9 @@ public void createSingleWorkspaceItemFromMultipleFilesWithOneEntryTest() throws
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile).file(pubmedFile))
.file(bibtexFile)
.file(pubmedFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -1879,6 +1898,7 @@ public void createSingleWorkspaceItemFromMultipleFilesWithOneEntryTest() throws
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile).file(pubmedFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
Expand Down Expand Up @@ -4323,6 +4343,7 @@ public void createWorkspaceItemFromExternalSources() throws Exception {
String token = getAuthToken(admin.getEmail(), password);
MvcResult mvcResult = getClient(token).perform(post("/api/submission/workspaceitems?owningCollection="
+ col1.getID().toString())
.param("embed", "item")
.contentType(parseMediaType(TEXT_URI_LIST_VALUE))
.content("https://localhost:8080/server/api/integration/" +
"externalsources/mock/entryValues/one"))
Expand All @@ -4333,7 +4354,8 @@ public void createWorkspaceItemFromExternalSources() throws Exception {
workspaceItemId = (Integer) map.get("id");
String itemUuidString = String.valueOf(((Map) ((Map) map.get("_embedded")).get("item")).get("uuid"));

getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId))
getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId)
.param("embed", "item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.allOf(
hasJsonPath("$.id", is(workspaceItemId)),
Expand Down Expand Up @@ -4528,6 +4550,7 @@ public void createWorkspaceItemFromExternalSourcesNonAdminWithPermission() throw

String token = getAuthToken(eperson.getEmail(), password);
getClient(token).perform(post("/api/submission/workspaceitems")
.param("embed", "collection")
.param("owningCollection", col1.getID().toString())
.contentType(parseMediaType(TEXT_URI_LIST_VALUE))
.content("https://localhost:8080/server/api/integration/externalsources/" +
Expand All @@ -4537,7 +4560,9 @@ public void createWorkspaceItemFromExternalSourcesNonAdminWithPermission() throw
.andDo(result -> idRef.set(read(result.getResponse().getContentAsString(), "$.id")));
workspaceItemId = idRef.get();

getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId))
getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId)
.param("embed", "collection")
.param("embed", "item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.allOf(
hasJsonPath("$.id", is(workspaceItemId)),
Expand Down

0 comments on commit d139d06

Please sign in to comment.