use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testMatchAllInstances.
@Test
public void testMatchAllInstances() {
Match query = qb.match(x.isa(Schema.MetaSchema.THING.getLabel().getValue()));
// Make sure there a reasonable number of results
assertThat(query, iterableWithSize(greaterThan(10)));
assertThat(query, variable(x, everyItem(isInstance())));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testRoleOnlyQuery.
@Test
public void testRoleOnlyQuery() {
Match query = qb.match(var().rel("actor", x));
assertThat(query, variable(x, containsInAnyOrder(marlonBrando, alPacino, missPiggy, kermitTheFrog, martinSheen, robertDeNiro, judeLaw, mirandaHeart, betteMidler, sarahJessicaParker)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testRelationshipQuery.
@Test
public void testRelationshipQuery() {
Match query = qb.match(x.isa("movie"), y.isa("person"), z.isa("character").has("name", "Don Vito Corleone"), var().rel(x).rel(y).rel(z));
assertThat(query, allOf(variable(x, contains(godfather)), variable(y, contains(marlonBrando))));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testKermitIsRelatedToSelfWhenMetaRoleIsSpecified.
@Test
public void testKermitIsRelatedToSelfWhenMetaRoleIsSpecified() {
Match query = qb.match(var().rel("role", x).rel(y).isa("has-cast"), y.has("name", "Kermit The Frog"));
assertThat(query, variable(x, (Matcher) hasItem(kermitTheFrog)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testAllLessThanAttachedResource.
@Test
public void testAllLessThanAttachedResource() {
Match query = qb.match(var("p").has("release-date", x), x.val(lte(y)));
assertThat(query, iterableWithSize(greaterThan(5)));
query.forEach(result -> {
Comparable cx = (Comparable) result.get(x).asAttribute().getValue();
Comparable cy = (Comparable) result.get(y).asAttribute().getValue();
assertThat(cx, lessThanOrEqualTo(cy));
});
}
Aggregations