use of ai.grakn.concept.Role in project grakn by graknlabs.
the class RoleTest method whenDeletingRoleTypeWithTypesWhichCanPlayIt_Throw.
@Test
public void whenDeletingRoleTypeWithTypesWhichCanPlayIt_Throw() {
Role foundType = tx.getRole("My Role");
assertNotNull(foundType);
foundType.delete();
assertNull(tx.getRole("My Role"));
Role role = tx.putRole("New Role Type");
tx.putEntityType("Entity Type").plays(role);
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(GraknTxOperationException.cannotBeDeleted(role).getMessage());
role.delete();
}
use of ai.grakn.concept.Role in project grakn by graknlabs.
the class RoleTest method whenAddingRoleTypeToMultipleRelationTypes_EnsureItLinkedToBothRelationTypes.
@Test
public void whenAddingRoleTypeToMultipleRelationTypes_EnsureItLinkedToBothRelationTypes() throws InvalidKBException {
Role roleA = tx.putRole("roleA");
Role roleB = tx.putRole("roleB");
relationshipType.relates(roleA).relates(role);
RelationshipType relationshipType2 = tx.putRelationshipType("relationshipType2").relates(roleB).relates(role);
tx.commit();
assertThat(roleA.relationshipTypes().collect(toSet()), containsInAnyOrder(relationshipType));
assertThat(roleB.relationshipTypes().collect(toSet()), containsInAnyOrder(relationshipType2));
assertThat(role.relationshipTypes().collect(toSet()), containsInAnyOrder(relationshipType, relationshipType2));
}
use of ai.grakn.concept.Role in project grakn by graknlabs.
the class RoleTest method whenDeletingRoleTypeWithRelationTypes_Throw.
@Test
public void whenDeletingRoleTypeWithRelationTypes_Throw() {
Role role2 = tx.putRole("New Role Type");
tx.putRelationshipType("Thing").relates(role2).relates(role);
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(GraknTxOperationException.cannotBeDeleted(role2).getMessage());
role2.delete();
}
use of ai.grakn.concept.Role in project grakn by graknlabs.
the class RoleTest method whenDeletingRoleTypeWithRolePlayers_Throw.
@Test
public void whenDeletingRoleTypeWithRolePlayers_Throw() {
Role roleA = tx.putRole("roleA");
Role roleB = tx.putRole("roleB");
RelationshipType relationshipType = tx.putRelationshipType("relationTypes").relates(roleA).relates(roleB);
EntityType entityType = tx.putEntityType("entityType").plays(roleA).plays(roleB);
Entity a = entityType.addEntity();
Entity b = entityType.addEntity();
relationshipType.addRelationship().addRolePlayer(roleA, a).addRolePlayer(roleB, b);
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(GraknTxOperationException.cannotBeDeleted(roleA).getMessage());
roleA.delete();
}
use of ai.grakn.concept.Role in project grakn by graknlabs.
the class SchemaMutationTest method whenAddingPlaysUsingBatchGraph_Throw.
@Test
public void whenAddingPlaysUsingBatchGraph_Throw() {
String roleTypeId = "role-thing";
String entityTypeId = "entityType";
tx.putRole(roleTypeId);
tx.putEntityType(entityTypeId);
EmbeddedGraknTx<?> graknGraphBatch = batchTx();
Role role = graknGraphBatch.getRole(roleTypeId);
EntityType entityType = graknGraphBatch.getEntityType(entityTypeId);
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(GraknTxOperationException.schemaMutation().getMessage());
entityType.plays(role);
}
Aggregations