use of ai.grakn.concept.RelationshipType in project grakn by graknlabs.
the class MigratorTestUtils method assertRelationBetweenInstancesExists.
public static void assertRelationBetweenInstancesExists(GraknTx graph, Thing thing1, Thing thing2, Label relation) {
RelationshipType relationshipType = graph.getSchemaConcept(relation);
Role role1 = thing1.plays().filter(r -> r.relationshipTypes().anyMatch(rel -> rel.equals(relationshipType))).findFirst().get();
assertTrue(thing1.relationships(role1).anyMatch(rel -> rel.rolePlayers().anyMatch(r -> r.equals(thing2))));
}
use of ai.grakn.concept.RelationshipType in project grakn by graknlabs.
the class GraknTxPutPropertyTest method whenCallingPutRelationType_CreateATypeThatOwnsNoRoles.
@Property
public void whenCallingPutRelationType_CreateATypeThatOwnsNoRoles(@Open GraknTx graph, @Unused Label label) {
RelationshipType relationshipType = graph.putRelationshipType(label);
assertThat(relationshipType.relates().collect(toSet()), empty());
}
use of ai.grakn.concept.RelationshipType in project grakn by graknlabs.
the class GraknTxPutPropertyTest method whenCallingPutRelationType_CreateATypeWithSuperTypeRelation.
@Property
public void whenCallingPutRelationType_CreateATypeWithSuperTypeRelation(@Open GraknTx tx, @Unused Label label) {
RelationshipType relationshipType = tx.putRelationshipType(label);
assertEquals(tx.admin().getMetaRelationType(), relationshipType.sup());
}
use of ai.grakn.concept.RelationshipType in project grakn by graknlabs.
the class GraknTxPutPropertyTest method whenCallingPutRelationTypeWithAnExistingRelationTypeLabel_ItReturnsThatType.
@Property
public void whenCallingPutRelationTypeWithAnExistingRelationTypeLabel_ItReturnsThatType(@Open GraknTx graph, @FromTx RelationshipType relationshipType) {
RelationshipType newType = graph.putRelationshipType(relationshipType.getLabel());
assertEquals(relationshipType, newType);
}
use of ai.grakn.concept.RelationshipType in project grakn by graknlabs.
the class ValidatorTest method whenCommittingWithRoleTypeHierarchyAndInstancesCannotPlayRolesExplicitly_Throw2.
@Test
public void whenCommittingWithRoleTypeHierarchyAndInstancesCannotPlayRolesExplicitly_Throw2() throws InvalidKBException {
Role parent = tx.putRole("parent");
Role child = tx.putRole("child");
EntityType person = tx.putEntityType("person").plays(child);
RelationshipType parenthood = tx.putRelationshipType("parenthood").relates(parent).relates(child);
Entity x = person.addEntity();
Entity y = person.addEntity();
parenthood.addRelationship().addRolePlayer(parent, x).addRolePlayer(child, y);
expectedException.expect(InvalidKBException.class);
expectedException.expectMessage(ErrorMessage.VALIDATION_CASTING.getMessage(person.getLabel(), x.getId(), parent.getLabel()));
tx.commit();
}
Aggregations