Search in sources :

Example 1 with RolePlayer

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));
}
Also used : Role(ai.grakn.concept.Role) RolePlayer(ai.grakn.grpc.RolePlayer) Thing(ai.grakn.concept.Thing) Test(org.junit.Test)

Example 2 with RolePlayer

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);
}
Also used : Role(ai.grakn.concept.Role) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) TxResponse(ai.grakn.rpc.generated.GrpcGrakn.TxResponse) RolePlayer(ai.grakn.grpc.RolePlayer) Thing(ai.grakn.concept.Thing) Test(org.junit.Test)

Aggregations

Role (ai.grakn.concept.Role)2 Thing (ai.grakn.concept.Thing)2 RolePlayer (ai.grakn.grpc.RolePlayer)2 Test (org.junit.Test)2 TxResponse (ai.grakn.rpc.generated.GrpcGrakn.TxResponse)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1