mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
added tests for RelationshipType 'byEntityType' end point
This commit is contained in:
@@ -254,5 +254,38 @@ public class RelationshipTypeRestRepositoryIT extends AbstractEntityIntegrationT
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByEntityTypePublicationTest() throws Exception {
|
||||
getClient().perform(get("/api/core/relationshiptypes/search/byEntityType")
|
||||
.param("type", "Publication"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.relationshiptypes", containsInAnyOrder(
|
||||
RelationshipTypeMatcher.matchExplicitRestrictedRelationshipTypeValues(1,
|
||||
"isAuthorOfPublication", "isPublicationOfAuthor"),
|
||||
RelationshipTypeMatcher.matchExplicitRestrictedRelationshipTypeValues(2,
|
||||
"isProjectOfPublication", "isPublicationOfProject"),
|
||||
RelationshipTypeMatcher.matchExplicitRestrictedRelationshipTypeValues(3,
|
||||
"isOrgUnitOfPublication", "isPublicationOfOrgUnit"),
|
||||
RelationshipTypeMatcher.matchExplicitRestrictedRelationshipTypeValues(10,
|
||||
"isAuthorOfPublication", "isPublicationOfAuthor"),
|
||||
RelationshipTypeMatcher.matchExplicitRestrictedRelationshipTypeValues(11,
|
||||
"isPublicationOfJournalIssue", "isJournalIssueOfPublication")
|
||||
)))
|
||||
.andExpect(jsonPath("$.page.totalElements", is(5)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByEntityTypeMissingParamTest() throws Exception {
|
||||
|
||||
getClient().perform(get("/api/core/relationshiptypes/search/byEntityType"))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByEntityTypeInvalidEntityTypeTest() throws Exception {
|
||||
getClient().perform(get("/api/core/relationshiptypes/search/byEntityType")
|
||||
.param("type", "WrongEntityType"))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -89,4 +89,13 @@ public class RelationshipTypeMatcher {
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
public static Matcher<? super Object> matchExplicitRestrictedRelationshipTypeValues(
|
||||
int id, String leftwardType, String rightwardType) {
|
||||
return allOf(hasJsonPath("$.id", is(id)),
|
||||
hasJsonPath("$.leftwardType", is(leftwardType)),
|
||||
hasJsonPath("$.rightwardType", is(rightwardType))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user