use of ai.grakn.graql.Match in project grakn by graknlabs.
the class DirectIsaTest method testMatchSyntax.
@Test
public void testMatchSyntax() {
QueryBuilder queryBuilder = tx.graql();
Match matchQuery;
GetQuery getQuery;
matchQuery = queryBuilder.match(x.directIsa(thingy1));
assertEquals("match $x isa! thingy1;", matchQuery.toString());
matchQuery = queryBuilder.match(x.directIsa(y));
assertEquals("match $x isa! $y;", matchQuery.toString());
getQuery = queryBuilder.parse("match $x isa! thingy1; get;");
assertEquals(queryBuilder.match(x.directIsa(thingy1)), getQuery.match());
getQuery = queryBuilder.parse("match $x isa! $y; get;");
assertEquals(queryBuilder.match(x.directIsa(y)), getQuery.match());
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class AdminTest method testGetTypesInQuery.
@Test
public void testGetTypesInQuery() {
Match match = qb.match(var("x").isa(label("movie").sub("production")).has("tmdb-vote-count", 400), var("y").isa("character"), var().rel("production-with-cast", "x").rel("y").isa("has-cast"));
Set<SchemaConcept> types = Stream.of("movie", "production", "tmdb-vote-count", "character", "production-with-cast", "has-cast").map(t -> rule.tx().<SchemaConcept>getSchemaConcept(Label.of(t))).collect(toSet());
assertEquals(types, match.admin().getSchemaConcepts());
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class DefineQueryTest method testDefineDataType.
@Test
public void testDefineDataType() {
qb.define(label("my-type").sub(Schema.MetaSchema.ATTRIBUTE.getLabel().getValue()).datatype(AttributeType.DataType.LONG)).execute();
Match match = qb.match(var("x").label("my-type"));
AttributeType.DataType datatype = match.iterator().next().get("x").asAttributeType().getDataType();
Assert.assertEquals(AttributeType.DataType.LONG, datatype);
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testNoInstancesOfRoleTypeUnselectedVariable.
@Test
public void testNoInstancesOfRoleTypeUnselectedVariable() {
Match query = qb.match(var().isa(y), y.label("actor"));
assertThat(query, emptyIterable());
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testDisconnectedQuery.
@Test
public void testDisconnectedQuery() {
Match query = qb.match(x.isa("movie"), y.isa("person"));
int numPeople = 10;
assertThat(Sets.newHashSet(query), hasSize(movies.size() * numPeople));
}
Aggregations