use of ai.grakn.concept.EntityType in project grakn by graknlabs.
the class GraknTxPutPropertyTest method whenCallingPutEntityTypeWithAnExistingEntityTypeLabel_ItReturnsThatType.
@Property
public void whenCallingPutEntityTypeWithAnExistingEntityTypeLabel_ItReturnsThatType(@Open GraknTx graph, @FromTx EntityType entityType) {
EntityType newType = graph.putEntityType(entityType.getLabel());
assertEquals(entityType, newType);
}
use of ai.grakn.concept.EntityType in project grakn by graknlabs.
the class ValidatorTest method whenCommittingRelationWithoutSpecifyingSchema_ThrowOnCommit.
@Test
public void whenCommittingRelationWithoutSpecifyingSchema_ThrowOnCommit() {
EntityType fakeType = tx.putEntityType("Fake Concept");
RelationshipType relationshipType = tx.putRelationshipType("kicks");
Role kicker = tx.putRole("kicker");
Role kickee = tx.putRole("kickee");
Thing kyle = fakeType.addEntity();
Thing icke = fakeType.addEntity();
relationshipType.addRelationship().addRolePlayer(kicker, kyle).addRolePlayer(kickee, icke);
String error1 = ErrorMessage.VALIDATION_CASTING.getMessage(kyle.type().getLabel(), kyle.getId(), kicker.getLabel());
String error2 = ErrorMessage.VALIDATION_CASTING.getMessage(icke.type().getLabel(), icke.getId(), kickee.getLabel());
expectedException.expect(InvalidKBException.class);
expectedException.expectMessage(allOf(containsString(error1), containsString(error2)));
tx.commit();
}
use of ai.grakn.concept.EntityType in project grakn by graknlabs.
the class EntityTypeTest method whenGettingTheSuperTypeOfType_ReturnSuperType.
@Test
public void whenGettingTheSuperTypeOfType_ReturnSuperType() {
EntityType c1 = tx.putEntityType("c1");
EntityType c2 = tx.putEntityType("c2").sup(c1);
EntityType c3 = tx.putEntityType("c3").sup(c2);
assertEquals(tx.admin().getMetaEntityType(), c1.sup());
assertEquals(c1, c2.sup());
assertEquals(c2, c3.sup());
}
use of ai.grakn.concept.EntityType in project grakn by graknlabs.
the class EntityTypeTest method whenDeletingTypeWithEntities_Throw.
@Test
public void whenDeletingTypeWithEntities_Throw() {
EntityType entityTypeA = tx.putEntityType("entityTypeA");
EntityType entityTypeB = tx.putEntityType("entityTypeB");
entityTypeB.addEntity();
entityTypeA.delete();
assertNull(tx.getEntityType("entityTypeA"));
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(GraknTxOperationException.cannotBeDeleted(entityTypeB).getMessage());
entityTypeB.delete();
}
use of ai.grakn.concept.EntityType in project grakn by graknlabs.
the class EntityTypeTest method whenCyclicSuperTypes_Throw.
@Test
public void whenCyclicSuperTypes_Throw() {
EntityType entityType1 = tx.putEntityType("Entity1");
EntityType entityType2 = tx.putEntityType("Entity2");
EntityType entityType3 = tx.putEntityType("Entity3");
entityType1.sup(entityType2);
entityType2.sup(entityType3);
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(GraknTxOperationException.loopCreated(entityType3, entityType1).getMessage());
entityType3.sup(entityType1);
}
Aggregations