diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/CollectionRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/CollectionRestRepositoryIT.java index 1e4287c2f8..64717e9792 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/CollectionRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/CollectionRestRepositoryIT.java @@ -88,9 +88,9 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$._embedded.collections", Matchers.containsInAnyOrder( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()), - CollectionMatcher.matchCollectionEntryFullProjection(col2.getName(), col2.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col2.getName(), col2.getID(), col2.getHandle()) ))); } @@ -225,12 +225,12 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$._embedded.collections", Matchers.contains( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._embedded.collections", Matchers.not( Matchers.contains( - CollectionMatcher.matchCollectionEntryFullProjection(col2.getName(), col2.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col2.getName(), col2.getID(), col2.getHandle()) ) ))); @@ -243,12 +243,12 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$._embedded.collections", Matchers.contains( - CollectionMatcher.matchCollectionEntryFullProjection(col2.getName(), col2.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col2.getName(), col2.getID(), col2.getHandle()) ))) .andExpect(jsonPath("$._embedded.collections", Matchers.not( Matchers.contains( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ) ))); @@ -283,7 +283,7 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) - .andExpect(jsonPath("$", CollectionMatcher.matchFullEmbeds())) + .andExpect(jsonPath("$", CollectionMatcher.matchSpecificEmbeds())) .andExpect(jsonPath("$", CollectionMatcher.matchCollectionEntry( col1.getName(), col1.getID(), col1.getHandle()))); @@ -418,12 +418,12 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", is( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$", Matchers.not( is( - CollectionMatcher.matchCollectionEntryFullProjection(col2.getName(), col2.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col2.getName(), col2.getID(), col2.getHandle()) ))) ) @@ -567,12 +567,12 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", is( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$", Matchers.not( is( - CollectionMatcher.matchCollectionEntryFullProjection(col2.getName(), col2.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col2.getName(), col2.getID(), col2.getHandle()) )))); } @@ -598,7 +598,7 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/core/collections"))) @@ -627,8 +627,8 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - CollectionMatcher.matchCollectionEntryFullProjection("Electronic theses and dissertations", - col1.getID(), col1.getHandle()) + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection( + "Electronic theses and dissertations", col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/core/collections"))) @@ -670,7 +670,7 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._links.self.href", @@ -716,7 +716,7 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._links.self.href", @@ -765,7 +765,7 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isCreated()) .andExpect(content().contentType(contentType)) - .andExpect(jsonPath("$", CollectionMatcher.matchFullEmbeds())) + .andExpect(jsonPath("$", CollectionMatcher.matchSpecificEmbeds())) .andExpect(jsonPath("$", Matchers.allOf( hasJsonPath("$.id", not(empty())), hasJsonPath("$.uuid", not(empty())), @@ -940,7 +940,7 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._links.self.href", @@ -978,7 +978,7 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/core/collections"))) @@ -1010,8 +1010,8 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - CollectionMatcher.matchCollectionEntryFullProjection("Electronic theses and dissertations", - col1.getID(), col1.getHandle()) + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection( + "Electronic theses and dissertations", col1.getID(), col1.getHandle()) ))) .andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/core/collections"))) @@ -1152,9 +1152,9 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$._embedded.collections", Matchers.containsInAnyOrder( - CollectionMatcher.matchCollectionEntryFullProjection(col1.getName(), col1.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col1.getName(), col1.getID(), col1.getHandle()), - CollectionMatcher.matchCollectionEntryFullProjection(col2.getName(), col2.getID(), + CollectionMatcher.matchCollectionEntrySpecificEmbedProjection(col2.getName(), col2.getID(), col2.getHandle()) ))) .andExpect(jsonPath("$.page", PageMatcher.pageEntryWithTotalPagesAndElements(0, 20, @@ -1307,10 +1307,8 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes context.restoreAuthSystemState(); - getClient().perform(get("/api/core/collections/" + col1.getID()) - .param("projection", "full")) + getClient().perform(get("/api/core/collections/" + col1.getID())) .andExpect(status().isOk()) - .andExpect(jsonPath("$", CollectionMatcher.matchFullEmbeds())) .andExpect(jsonPath("$", CollectionMatcher.matchProperties(col1.getName(), col1.getID(), col1.getHandle()))) @@ -1338,10 +1336,8 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes String token = getAuthToken(admin.getEmail(), password); - getClient(token).perform(get("/api/core/collections/" + col1.getID()) - .param("projection", "full")) + getClient(token).perform(get("/api/core/collections/" + col1.getID())) .andExpect(status().isOk()) - .andExpect(jsonPath("$", CollectionMatcher.matchFullEmbeds())) .andExpect(jsonPath("$", CollectionMatcher.matchProperties(col1.getName(), col1.getID(), col1.getHandle()))) @@ -1373,10 +1369,8 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes String token = getAuthToken(eperson.getEmail(), password); - getClient(token).perform(get("/api/core/collections/" + col1.getID()) - .param("projection", "full")) + getClient(token).perform(get("/api/core/collections/" + col1.getID())) .andExpect(status().isOk()) - .andExpect(jsonPath("$", CollectionMatcher.matchFullEmbeds())) .andExpect(jsonPath("$", CollectionMatcher.matchProperties(col1.getName(), col1.getID(), col1.getHandle()))) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ItemRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ItemRestRepositoryIT.java index b0de436dac..8f19ec97e2 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ItemRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ItemRestRepositoryIT.java @@ -2576,10 +2576,8 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest { context.restoreAuthSystemState(); - getClient().perform(get("/api/core/items/" + item.getID()) - .param("projection", "full")) + getClient().perform(get("/api/core/items/" + item.getID())) .andExpect(status().isOk()) - .andExpect(jsonPath("$", ItemMatcher.matchFullEmbeds())) .andExpect(jsonPath("$", ItemMatcher.matchItemProperties(item))) .andExpect(jsonPath("$.metadata", matchMetadata("dc.title", "Public item 1"))) .andExpect(jsonPath("$.metadata", matchMetadataDoesNotExist("dc.description.provenance"))); @@ -2603,10 +2601,8 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest { String token = getAuthToken(admin.getEmail(), password); - getClient(token).perform(get("/api/core/items/" + item.getID()) - .param("projection", "full")) + getClient(token).perform(get("/api/core/items/" + item.getID())) .andExpect(status().isOk()) - .andExpect(jsonPath("$", ItemMatcher.matchFullEmbeds())) .andExpect(jsonPath("$", ItemMatcher.matchItemProperties(item))) .andExpect(jsonPath("$.metadata", matchMetadata("dc.title", "Public item 1"))) .andExpect(jsonPath("$.metadata", matchMetadata("dc.description.provenance", "Provenance data"))); @@ -2637,10 +2633,8 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest { String token = getAuthToken(eperson.getEmail(), password); - getClient(token).perform(get("/api/core/items/" + item.getID()) - .param("projection", "full")) + getClient(token).perform(get("/api/core/items/" + item.getID())) .andExpect(status().isOk()) - .andExpect(jsonPath("$", ItemMatcher.matchFullEmbeds())) .andExpect(jsonPath("$", ItemMatcher.matchItemProperties(item))) .andExpect(jsonPath("$.metadata", matchMetadata("dc.title", "Public item 1"))) .andExpect(jsonPath("$.metadata", matchMetadataDoesNotExist("dc.description.provenance"))); diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/CollectionMatcher.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/CollectionMatcher.java index 2d2f788477..5afb4155bd 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/CollectionMatcher.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/CollectionMatcher.java @@ -51,6 +51,22 @@ public class CollectionMatcher { ); } + public static Matcher matchCollectionEntrySpecificEmbedProjection(String name, UUID uuid, + String handle) { + return matchCollectionEntrySpecificEmbedProjection(name, uuid, handle, null); + + } + + public static Matcher matchCollectionEntrySpecificEmbedProjection(String name, UUID uuid, + String handle, Bitstream logo) { + return allOf( + matchProperties(name, uuid, handle), + matchLinks(uuid), + matchLogo(logo), + matchSpecificEmbeds() + ); + } + public static Matcher matchProperties(String name, UUID uuid, String handle) { return allOf( hasJsonPath("$.uuid", is(uuid.toString())), @@ -70,7 +86,11 @@ public class CollectionMatcher { "license", "logo", "parentCommunity", - "mappedItems[]" + "mappedItems[]", + "adminGroup", + "submittersGroup", + "itemReadGroup", + "bitstreamReadGroup" ); } @@ -119,4 +139,12 @@ public class CollectionMatcher { hasJsonPath("$.type", is("collection")), hasJsonPath("$.handle", is(collection.getHandle()))); } + + /** + * Gets a matcher for all expected embeds when the embeds parameter is requested. + */ + public static Matcher matchSpecificEmbeds() { + return matchEmbeds(getEmbedsParameter().split(",") + ); + } }