Search in sources :

Example 36 with Label

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

the class DefineQueryTest method whenSpecifyingLabelOfAnExistingConcept_LabelIsChanged.

@Test
public void whenSpecifyingLabelOfAnExistingConcept_LabelIsChanged() {
    movies.tx().putEntityType("a-new-type");
    EntityType type = movies.tx().getEntityType("a-new-type");
    Label newLabel = Label.of("a-new-new-type");
    qb.define(label(newLabel).id(type.getId())).execute();
    assertEquals(newLabel, type.getLabel());
}
Also used : EntityType(ai.grakn.concept.EntityType) Label(ai.grakn.concept.Label) Test(org.junit.Test)

Example 37 with Label

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

the class RelationshipPropertyTest method whenCheckingRoleIsAValidRelationType_Throw.

@Test
public void whenCheckingRoleIsAValidRelationType_Throw() {
    RelationshipProperty property = RelationshipProperty.of(ImmutableMultiset.of());
    Label role = Schema.MetaSchema.ROLE.getLabel();
    exception.expect(GraqlQueryException.class);
    exception.expectMessage(GraqlQueryException.notARelationType(role).getMessage());
    property.checkValidProperty(sampleKB.tx(), var("x").isa(label(role)).admin());
}
Also used : Label(ai.grakn.concept.Label) Test(org.junit.Test)

Example 38 with Label

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

the class RolePlayerFragmentSetTest method whenRelationTypeIsNotInGraph_DoNotApplyRelationTypeOptimisation.

@Test
public void whenRelationTypeIsNotInGraph_DoNotApplyRelationTypeOptimisation() {
    Label magician = Label.of("magician");
    Collection<EquivalentFragmentSet> fragmentSets = Sets.newHashSet(EquivalentFragmentSets.rolePlayer(null, a, b, c, null), EquivalentFragmentSets.isa(null, a, d, true), EquivalentFragmentSets.label(null, d, ImmutableSet.of(magician)));
    Collection<EquivalentFragmentSet> expected = Sets.newHashSet(fragmentSets);
    RolePlayerFragmentSet.RELATION_TYPE_OPTIMISATION.apply(fragmentSets, sampleKB.tx());
    assertEquals(expected, fragmentSets);
}
Also used : Label(ai.grakn.concept.Label) EquivalentFragmentSet(ai.grakn.graql.internal.gremlin.EquivalentFragmentSet) Test(org.junit.Test)

Example 39 with Label

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

the class RolePlayerFragmentSetTest method whenApplyingRoleOptimisation_ExpandRoleToAllSubs.

@Test
public void whenApplyingRoleOptimisation_ExpandRoleToAllSubs() {
    Label author = Label.of("author");
    Label director = Label.of("director");
    EquivalentFragmentSet authorLabelFragmentSet = EquivalentFragmentSets.label(null, d, ImmutableSet.of(author));
    Collection<EquivalentFragmentSet> fragmentSets = Sets.newHashSet(EquivalentFragmentSets.rolePlayer(null, a, b, c, d), authorLabelFragmentSet);
    RolePlayerFragmentSet.ROLE_OPTIMISATION.apply(fragmentSets, sampleKB.tx());
    HashSet<EquivalentFragmentSet> expected = Sets.newHashSet(RolePlayerFragmentSet.of(null, a, b, c, null, ImmutableSet.of(author, director), null), authorLabelFragmentSet);
    assertEquals(expected, fragmentSets);
}
Also used : Label(ai.grakn.concept.Label) EquivalentFragmentSet(ai.grakn.graql.internal.gremlin.EquivalentFragmentSet) Test(org.junit.Test)

Example 40 with Label

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

the class RolePlayerFragmentSetTest method whenApplyingRoleOptimisationToMetaRole_DoNotExpandRoleToAllSubs.

@Test
public void whenApplyingRoleOptimisationToMetaRole_DoNotExpandRoleToAllSubs() {
    Label role = Label.of("role");
    EquivalentFragmentSet authorLabelFragmentSet = EquivalentFragmentSets.label(null, d, ImmutableSet.of(role));
    Collection<EquivalentFragmentSet> fragmentSets = Sets.newHashSet(EquivalentFragmentSets.rolePlayer(null, a, b, c, d), authorLabelFragmentSet);
    RolePlayerFragmentSet.ROLE_OPTIMISATION.apply(fragmentSets, sampleKB.tx());
    HashSet<EquivalentFragmentSet> expected = Sets.newHashSet(RolePlayerFragmentSet.of(null, a, b, c, null, null, null), authorLabelFragmentSet);
    assertEquals(expected, fragmentSets);
}
Also used : Label(ai.grakn.concept.Label) EquivalentFragmentSet(ai.grakn.graql.internal.gremlin.EquivalentFragmentSet) Test(org.junit.Test)

Aggregations

Label (ai.grakn.concept.Label)87 Test (org.junit.Test)41 Role (ai.grakn.concept.Role)25 GraknTx (ai.grakn.GraknTx)22 ConceptId (ai.grakn.concept.ConceptId)21 Concept (ai.grakn.concept.Concept)20 Set (java.util.Set)20 RelationshipType (ai.grakn.concept.RelationshipType)19 SchemaConcept (ai.grakn.concept.SchemaConcept)19 AttributeType (ai.grakn.concept.AttributeType)17 EntityType (ai.grakn.concept.EntityType)17 Relationship (ai.grakn.concept.Relationship)14 HashSet (java.util.HashSet)14 Collectors (java.util.stream.Collectors)13 Type (ai.grakn.concept.Type)12 Stream (java.util.stream.Stream)12 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)11 Schema (ai.grakn.util.Schema)11 Collection (java.util.Collection)11 Pattern (ai.grakn.graql.Pattern)10