use of ai.grakn.engine.controller.response.RolePlayer in project grakn by graknlabs.
the class ConceptControllerTest method whenGettingRelationships_EnsureRolePlayersAreReturned.
@Test
public void whenGettingRelationships_EnsureRolePlayersAreReturned() throws IOException {
// Get Expected Relationships
Set<RolePlayer> relationshipsExpected = new HashSet<>();
try (GraknTx tx = factory.tx(keyspace, GraknTxType.READ)) {
entity.plays().forEach(role -> {
Link roleWrapper = Link.create(role);
entity.relationships(role).forEach(relationship -> {
Link relationshipWrapper = Link.create(relationship);
relationshipsExpected.add(RolePlayer.create(roleWrapper, relationshipWrapper));
});
});
}
// Make the request
String request = entityWrapper.relationships().id();
Response response = RestAssured.when().get(request);
assertEquals(SC_OK, response.getStatusCode());
// Check relationships are embedded
RolePlayer[] relationships = response.jsonPath().getObject("relationships", RolePlayer[].class);
assertThat(relationships, arrayContainingInAnyOrder(relationshipsExpected.toArray()));
}
Aggregations