use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testMoviesReleasedBeforeTheMuppets.
@Test
public void testMoviesReleasedBeforeTheMuppets() {
Match query = qb.match(x.has("release-date", lt(r)), var().has("title", "The Muppets").has("release-date", r));
assertThat(query, variable(x, contains(godfather)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testRobertDeNiroNotRelatedToSelf.
@Test
public void testRobertDeNiroNotRelatedToSelf() {
Match query = qb.match(var().rel(x).rel(y).isa("has-cast"), y.has("name", "Robert de Niro"));
assertThat(query, variable(x, containsInAnyOrder(heat, neilMcCauley)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testMatchAllResourcesUsingResourceName.
@Test
public void testMatchAllResourcesUsingResourceName() {
Match match = qb.match(var().has("title", "Godfather").has(Schema.MetaSchema.ATTRIBUTE.getLabel().getValue(), x));
Thing godfather = movieKB.tx().getAttributeType("title").getAttribute("Godfather").owner();
Set<Attribute<?>> expected = godfather.attributes().collect(toSet());
Set<Attribute<?>> results = match.get(x).map(Concept::asAttribute).collect(toSet());
assertEquals(expected, results);
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testDistinctTuple.
@Test
public void testDistinctTuple() {
int size = (int) movieKB.tx().graql().match(x.isa("genre")).stream().count();
size *= size;
Match match1 = movieKB.tx().graql().match(x.isa("genre"), x.isa("genre"), x.isa("genre"), y.isa("genre"));
assertThat(match1, iterableWithSize(size));
Match match2 = movieKB.tx().graql().match(var().isa("genre"), var().isa("genre"), var().isa("genre"), var().isa("genre"), var().isa("genre"));
assertThat(match2, iterableWithSize(1));
Match match3 = movieKB.tx().graql().match(x.isa("genre"), y.isa("genre"));
assertThat(match3, iterableWithSize(size));
Match match4 = movieKB.tx().graql().match(var().isa("genre"), x.isa("genre"), y.isa("genre"));
assertThat(match4, iterableWithSize(size));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testAssertionQuery.
@Test
public void testAssertionQuery() {
Match query = qb.match(var("a").rel("production-with-cast", x).rel(y), y.has("name", "Miss Piggy"), var("a").isa("has-cast"));
assertThat(query, variable(x, contains(theMuppets)));
}
Aggregations