use of ai.grakn.GraknTx in project grakn by graknlabs.
the class OntologicalQueryTest method allInstancesAndTheirType.
// TODO need to correctly return THING and RELATIONSHIP mapping for %type
@Ignore
@Test
public void allInstancesAndTheirType() {
GraknTx tx = testContext.tx();
QueryBuilder qb = tx.graql().infer(true);
String queryString = "match $x isa $type; get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
assertCollectionsEqual(answers, qb.infer(false).<GetQuery>parse(queryString).execute());
}
use of ai.grakn.GraknTx in project grakn by graknlabs.
the class OntologicalQueryTest method allInstancesOfMetaEntity.
/**
* meta concepts *
*/
@Test
public void allInstancesOfMetaEntity() {
GraknTx tx = testContext.tx();
QueryBuilder qb = tx.graql().infer(true);
long noOfEntities = tx.admin().getMetaEntityType().instances().count();
String queryString = "match $x isa entity;get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
assertEquals(answers.size(), noOfEntities);
}
use of ai.grakn.GraknTx in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryContainingLimit.
@Test
public void testReasoningWithQueryContainingLimit() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String limitQueryString = "match (geo-entity: $x, entity-location: $y)isa is-located-in;limit 5; get;";
String queryString = "match (geo-entity: $x, entity-location: $y)isa is-located-in; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery limitQuery = iqb.parse(limitQueryString);
GetQuery query = iqb.parse(queryString);
List<Answer> limitedAnswers = limitQuery.execute();
List<Answer> answers = query.execute();
assertEquals(limitedAnswers.size(), 5);
assertTrue(answers.size() > limitedAnswers.size());
assertTrue(answers.containsAll(limitedAnswers));
}
use of ai.grakn.GraknTx in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryWithNoRelationTypeWithRoles2.
@Test
public void testReasoningWithQueryWithNoRelationTypeWithRoles2() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match $x isa city;$y isa country;(geo-entity: $x, $y); get;";
String queryString2 = "match $x isa city;$y isa country;" + "(geo-entity: $x, entity-location: $y) isa is-located-in; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.GraknTx in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryWithNoRelationTypeWithRoles.
@Test
public void testReasoningWithQueryWithNoRelationTypeWithRoles() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match $x isa city;$y isa country;(geo-entity: $x, $y);$y has name 'Poland'; get;";
String queryString2 = "match $x isa city;$y isa country;" + "(geo-entity: $x, entity-location: $y) isa is-located-in;$y has name 'Poland'; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
Aggregations