use of ai.grakn.grpc.RolePlayer in project grakn by graknlabs.
the class RemoteConceptsTest method whenCallingRolePlayersWithNoArguments_GetTheExpectedResult.
@Test
public void whenCallingRolePlayersWithNoArguments_GetTheExpectedResult() {
Role foo = RemoteConcepts.createRole(tx, ConceptId.of("foo"));
Thing a = RemoteConcepts.createEntity(tx, A);
Thing b = RemoteConcepts.createRelationship(tx, B);
Thing c = RemoteConcepts.createAttribute(tx, C);
Stream<RolePlayer> expected = Stream.of(RolePlayer.create(foo, a), RolePlayer.create(foo, b), RolePlayer.create(foo, c));
mockConceptMethod(ConceptMethods.GET_ROLE_PLAYERS, expected);
assertThat(relationship.rolePlayers().collect(toSet()), containsInAnyOrder(a, b, c));
}
use of ai.grakn.grpc.RolePlayer in project grakn by graknlabs.
the class RemoteConceptsTest method whenCallingAllRolePlayers_GetTheExpectedResult.
@Test
public void whenCallingAllRolePlayers_GetTheExpectedResult() {
Role foo = RemoteConcepts.createRole(tx, ConceptId.of("foo"));
Role bar = RemoteConcepts.createRole(tx, ConceptId.of("bar"));
Thing a = RemoteConcepts.createEntity(tx, A);
Thing b = RemoteConcepts.createRelationship(tx, B);
Thing c = RemoteConcepts.createAttribute(tx, C);
Stream<RolePlayer> mockedResponse = Stream.of(RolePlayer.create(foo, a), RolePlayer.create(bar, b), RolePlayer.create(bar, c));
TxResponse response = GET_ROLE_PLAYERS.createTxResponse(server.grpcIterators(), mockedResponse);
server.setResponse(GrpcUtil.runConceptMethodRequest(ID, GET_ROLE_PLAYERS), response);
Map<Role, Set<Thing>> allRolePlayers = relationship.allRolePlayers();
Map<Role, Set<Thing>> expected = ImmutableMap.of(foo, ImmutableSet.of(a), bar, ImmutableSet.of(b, c));
assertEquals(expected, allRolePlayers);
}
Aggregations