use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GrpcServerIT method whenGettingARole_TheInformationOnTheRoleIsCorrect.
@Test
public void whenGettingARole_TheInformationOnTheRoleIsCorrect() {
try (GraknTx remoteTx = remoteSession.open(GraknTxType.READ);
GraknTx localTx = localSession.open(GraknTxType.READ)) {
GetQuery query = remoteTx.graql().match(var("x").label("actor")).get();
Role remoteConcept = query.stream().findAny().get().get("x").asRole();
Role localConcept = localTx.getConcept(remoteConcept.getId()).asRole();
assertEqualConcepts(localConcept, remoteConcept, Role::playedByTypes);
assertEqualConcepts(localConcept, remoteConcept, Role::relationshipTypes);
}
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GrpcServerIT method whenGettingAnEntityType_TheInformationOnTheEntityTypeIsCorrect.
@Test
public void whenGettingAnEntityType_TheInformationOnTheEntityTypeIsCorrect() {
try (GraknTx remoteTx = remoteSession.open(GraknTxType.READ);
GraknTx localTx = localSession.open(GraknTxType.READ)) {
GetQuery query = remoteTx.graql().match(var("x").label("person")).get();
EntityType remoteConcept = query.stream().findAny().get().get("x").asEntityType();
EntityType localConcept = localTx.getConcept(remoteConcept.getId()).asEntityType();
// There actually aren't any new methods on EntityType, but we should still check we can get them
assertEquals(localConcept.getId(), remoteConcept.getId());
}
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GrpcServerIT method whenExecutingAnInvalidQuery_Throw.
@Test
public void whenExecutingAnInvalidQuery_Throw() throws Throwable {
try (GraknTx tx = remoteSession.open(GraknTxType.READ)) {
GetQuery query = tx.graql().match(var("x").isa("not-a-thing")).get();
exception.expect(GraqlQueryException.class);
exception.expectMessage(GraqlQueryException.labelNotFound(Label.of("not-a-thing")).getMessage());
query.execute();
}
}
use of ai.grakn.graql.GetQuery 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.GetQuery in project grakn by graknlabs.
the class QueryParserTest method whenSearchingForImplicitType_EnsureQueryCanBeParsed.
@Test
public void whenSearchingForImplicitType_EnsureQueryCanBeParsed() {
GetQuery expected = match(var("x").plays("@has-release-date-owner")).get();
GetQuery parsed = parse("match $x plays @has-release-date-owner; get;");
assertEquals(expected, parsed);
}
Aggregations