use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testSelectRuleTypes.
@Test
public void testSelectRuleTypes() {
Match query = qb.match(x.sub(RULE.getLabel().getValue()));
assertThat(query, variable(x, containsInAnyOrder(rule, materializeRule, expectationRule)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testRegexResourceType.
@Test
public void testRegexResourceType() {
Match query = qb.match(x.regex("(fe)?male"));
assertThat(query, variable(x, contains(gender)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method whenReferringToImplicitRelationsAndRoles_DontHideResults.
@Test
public void whenReferringToImplicitRelationsAndRoles_DontHideResults() {
VarPattern hasTitle = label(HAS.getLabel("title"));
VarPattern titleOwner = label(HAS_OWNER.getLabel("title"));
VarPattern titleValue = label(HAS_VALUE.getLabel("title"));
Match hasQuery = qb.match(y.has("title", z));
Match explicitQuery = qb.match(var().isa(hasTitle).rel(titleOwner, y).rel(titleValue, z));
assertEquals(hasQuery.stream().collect(toSet()), explicitQuery.stream().collect(toSet()));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testVariableAsRoleType.
@Test
public void testVariableAsRoleType() {
Match query = qb.match(var().rel(var().label("genre-of-production"), y));
assertThat(query, variable(y, containsInAnyOrder(crime, drama, war, action, comedy, family, musical, fantasy)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testMatchAllDistinctPairs.
@Test
public void testMatchAllDistinctPairs() {
int numConcepts = (int) qb.match(x).stream().count();
Match pairs = qb.match(x.neq(y));
// We expect there to be a result for every distinct pair of concepts
assertThat(pairs, iterableWithSize(numConcepts * (numConcepts - 1)));
}
Aggregations