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 4703934 commit 366004d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
Expand Up @@ -5832,10 +5832,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 @@ -5849,12 +5845,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 @@ -5919,14 +5909,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
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
Expand Up @@ -881,6 +881,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 @@ -889,6 +890,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 @@ -897,10 +899,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 @@ -948,7 +950,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 @@ -977,6 +980,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 @@ -1040,7 +1044,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 @@ -1074,6 +1079,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 @@ -1137,7 +1143,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 @@ -1168,6 +1175,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 @@ -1234,7 +1242,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 @@ -1274,6 +1283,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 @@ -1339,7 +1349,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 @@ -1379,6 +1390,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 @@ -1456,7 +1468,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 @@ -1534,7 +1547,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 @@ -1610,7 +1624,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 @@ -1687,7 +1702,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 @@ -1766,7 +1782,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 @@ -1847,7 +1864,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 @@ -1882,6 +1901,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 @@ -4326,6 +4346,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 @@ -4336,7 +4357,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 @@ -4531,6 +4553,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 @@ -4540,7 +4563,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 366004d

Please sign in to comment.