added tests for RelationshipType 'byEntityType' end point

This commit is contained in:
Mykhaylo
2021-09-06 21:38:37 +02:00
parent 1123e0b700
commit 5bb9fce3b6
2 changed files with 42 additions and 0 deletions

View File

@@ -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());
}
}

View File

@@ -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))
);
}
}