Search in sources :

Example 36 with Attribute

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

the class EntityTest method whenAddingResourceToEntityWithoutAllowingItBetweenTypes_Throw.

@Test
public void whenAddingResourceToEntityWithoutAllowingItBetweenTypes_Throw() {
    EntityType entityType = tx.putEntityType("A Thing");
    AttributeType<String> attributeType = tx.putAttributeType("A Attribute Thing", AttributeType.DataType.STRING);
    Entity entity = entityType.addEntity();
    Attribute attribute = attributeType.putAttribute("A attribute thing");
    expectedException.expect(GraknTxOperationException.class);
    expectedException.expectMessage(GraknTxOperationException.hasNotAllowed(entity, attribute).getMessage());
    entity.attribute(attribute);
}
Also used : EntityType(ai.grakn.concept.EntityType) Entity(ai.grakn.concept.Entity) Attribute(ai.grakn.concept.Attribute) Test(org.junit.Test)

Aggregations

Attribute (ai.grakn.concept.Attribute)36 Test (org.junit.Test)26 GraknTx (ai.grakn.GraknTx)15 EntityType (ai.grakn.concept.EntityType)15 Entity (ai.grakn.concept.Entity)14 RelationshipType (ai.grakn.concept.RelationshipType)10 Set (java.util.Set)10 Role (ai.grakn.concept.Role)9 AttributeType (ai.grakn.concept.AttributeType)8 Relationship (ai.grakn.concept.Relationship)8 Label (ai.grakn.concept.Label)7 Thing (ai.grakn.concept.Thing)6 Concept (ai.grakn.concept.Concept)5 HashSet (java.util.HashSet)5 ConceptId (ai.grakn.concept.ConceptId)4 Schema (ai.grakn.util.Schema)4 GraknTxOperationException (ai.grakn.exception.GraknTxOperationException)3 Sets (com.google.common.collect.Sets)3 Collection (java.util.Collection)3 Collectors (java.util.stream.Collectors)3