Search in sources :

Example 51 with Role

use of ai.grakn.concept.Role in project grakn by graknlabs.

the class RemoteConceptsTest method whenSettingRelates_ExecuteAConceptMethod.

@Test
public void whenSettingRelates_ExecuteAConceptMethod() {
    Role role = RemoteConcepts.createRole(tx, A);
    assertEquals(relationshipType, relationshipType.relates(role));
    verifyConceptMethodCalled(ConceptMethods.setRelatedRole(role));
}
Also used : Role(ai.grakn.concept.Role) Test(org.junit.Test)

Example 52 with Role

use of ai.grakn.concept.Role in project grakn by graknlabs.

the class RemoteConceptsTest method whenDeletingPlays_ExecuteAConceptMethod.

@Test
public void whenDeletingPlays_ExecuteAConceptMethod() {
    Role role = RemoteConcepts.createRole(tx, A);
    assertEquals(type, type.deletePlays(role));
    verifyConceptMethodCalled(ConceptMethods.unsetRolePlayedByType(role));
}
Also used : Role(ai.grakn.concept.Role) Test(org.junit.Test)

Example 53 with Role

use of ai.grakn.concept.Role in project grakn by graknlabs.

the class RemoteConceptsTest method whenCallingAddRolePlayer_ExecuteAConceptMethod.

@Test
public void whenCallingAddRolePlayer_ExecuteAConceptMethod() {
    Role role = RemoteConcepts.createRole(tx, A);
    Thing thing = RemoteConcepts.createEntity(tx, B);
    assertEquals(relationship, relationship.addRolePlayer(role, thing));
    verifyConceptMethodCalled(ConceptMethods.setRolePlayer(RolePlayer.create(role, thing)));
}
Also used : Role(ai.grakn.concept.Role) Thing(ai.grakn.concept.Thing) Test(org.junit.Test)

Example 54 with Role

use of ai.grakn.concept.Role 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 55 with Role

use of ai.grakn.concept.Role in project grakn by graknlabs.

the class RemoteConceptsTest method whenCallingThingPlays_GetTheExpectedResult.

@Test
public void whenCallingThingPlays_GetTheExpectedResult() {
    Role a = RemoteConcepts.createRole(tx, A);
    Role b = RemoteConcepts.createRole(tx, B);
    Role c = RemoteConcepts.createRole(tx, C);
    mockConceptMethod(ConceptMethods.GET_ROLES_PLAYED_BY_THING, Stream.of(a, b, c));
    assertThat(thing.plays().collect(toSet()), containsInAnyOrder(a, b, c));
}
Also used : Role(ai.grakn.concept.Role) Test(org.junit.Test)

Aggregations

Role (ai.grakn.concept.Role)189 Test (org.junit.Test)124 RelationshipType (ai.grakn.concept.RelationshipType)114 EntityType (ai.grakn.concept.EntityType)92 Entity (ai.grakn.concept.Entity)55 GraknTx (ai.grakn.GraknTx)48 Relationship (ai.grakn.concept.Relationship)37 Set (java.util.Set)36 ConceptId (ai.grakn.concept.ConceptId)33 Label (ai.grakn.concept.Label)33 Thing (ai.grakn.concept.Thing)32 HashSet (java.util.HashSet)31 Var (ai.grakn.graql.Var)25 AttributeType (ai.grakn.concept.AttributeType)21 Concept (ai.grakn.concept.Concept)20 Schema (ai.grakn.util.Schema)17 Collectors (java.util.stream.Collectors)17 Attribute (ai.grakn.concept.Attribute)16 SchemaConcept (ai.grakn.concept.SchemaConcept)16 Type (ai.grakn.concept.Type)16