use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class QueryValidityTest method whenQueryingForMismatchedResourceTypeLabel_Throws.
@Test
public void whenQueryingForMismatchedResourceTypeLabel_Throws() throws GraqlQueryException {
QueryBuilder qb = testContext.tx().graql().infer(true);
String queryString = "match $x has binary $r; get;";
expectedException.expect(GraqlQueryException.class);
qb.<GetQuery>parse(queryString).execute();
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class QueryValidityTest method whenQueryingForInexistentRelationTypeLabelViaVariable_emptyResultReturned.
@Test
public void whenQueryingForInexistentRelationTypeLabelViaVariable_emptyResultReturned() {
QueryBuilder qb = testContext.tx().graql().infer(true);
String queryString = "match ($x, $y) isa $type; $type label jakas-relacja; get;";
assertThat(qb.<GetQuery>parse(queryString).execute(), empty());
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class RecursiveInferenceTest method testPathSymmetric.
@Test
public void testPathSymmetric() {
final int N = 2;
SampleKBContext kb = PathTreeSymmetricKB.context(N, 3);
QueryBuilder qb = kb.tx().graql().infer(false);
QueryBuilder iqb = kb.tx().graql().infer(true);
String queryString = "match ($x, $y) isa path;$x has index 'a0'; get $y;";
String explicitQuery = "match {$y isa vertex;} or {$y isa start-vertex;}; get;";
assertQueriesEqual(iqb.materialise(false).parse(queryString), qb.parse(explicitQuery));
assertQueriesEqual(iqb.materialise(true).parse(queryString), qb.parse(explicitQuery));
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class RecursiveInferenceTest method testReachabilitySymmetric.
@Test
public void testReachabilitySymmetric() {
QueryBuilder qb = reachabilitySymmetricContext.tx().graql().infer(false);
QueryBuilder iqb = reachabilitySymmetricContext.tx().graql().infer(true);
String queryString = "match ($x, $y) isa reachable;$x has index 'a';get $y;";
String explicitQuery = "match $y has index $indY;" + "{$indY val 'a';} or {$indY val 'b';} or {$indY val 'c';} or {$indY val 'd';};get $y;";
assertQueriesEqual(iqb.materialise(false).parse(queryString), qb.parse(explicitQuery));
assertQueriesEqual(iqb.materialise(true).parse(queryString), qb.parse(explicitQuery));
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class RecursiveInferenceTest method testReverseSameGeneration.
/**
*from Abiteboul - Foundations of databases p. 312/Cao test 6.14 p. 89
*/
@Test
public void testReverseSameGeneration() {
QueryBuilder qb = recursivityRSGContext.tx().graql().infer(false);
QueryBuilder iqb = recursivityRSGContext.tx().graql().infer(true);
String queryString = "match (RSG-from: $x, RSG-to: $y) isa RevSG;$x has name 'a'; get $y;";
String explicitQuery = "match $y isa person, has name $name;" + "{$name val 'b';} or {$name val 'c';} or {$name val 'd';};get $y;";
assertQueriesEqual(iqb.materialise(false).parse(queryString), qb.parse(explicitQuery));
assertQueriesEqual(iqb.materialise(true).parse(queryString), qb.parse(explicitQuery));
}
Aggregations