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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations