use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GenealogyTest method testSon.
/*
test for the last rule-file:
match (mother: $x);
match (son: $x);
match (grandfather: $x); (grandparent: $x, grandchild: $y);
*/
@Test
public void testSon() {
String queryString = "match (son: $x);$x has gender $g; get;";
GetQuery query = iqb.parse(queryString);
List<Answer> answers = query.execute();
assertEquals(answers.size(), 18);
assertCollectionsEqual(answers, qb.<GetQuery>parse(queryString).execute());
assertTrue(checkResource(answers, "g", "male"));
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GenealogyTest method testDaughter.
@Test
public void testDaughter() {
String queryString = "match (daughter: $x);$x has gender $g; get;";
GetQuery query = iqb.parse(queryString);
List<Answer> answers = query.execute();
assertEquals(answers.size(), 20);
assertCollectionsEqual(answers, qb.<GetQuery>parse(queryString).execute());
assertTrue(checkResource(answers, "g", "female"));
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GenealogyTest method testCousins.
@Test
public void testCousins() {
String queryString = "match ($x, $y) isa cousins; get;";
GetQuery query = iqb.parse(queryString);
List<Answer> answers = query.execute();
assertEquals(answers.size(), 192);
assertTrue(!hasDuplicates(answers));
assertCollectionsEqual(answers, qb.<GetQuery>parse(queryString).execute());
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GenealogyTest method testGrandMother.
@Test
public void testGrandMother() {
String queryString = "match (grandmother: $x) isa grandparentship; $x has gender $g; get;";
GetQuery query = iqb.parse(queryString);
List<Answer> answers = query.execute();
assertEquals(answers.size(), 4);
assertTrue(checkResource(answers, "g", "female"));
assertCollectionsEqual(answers, qb.<GetQuery>parse(queryString).execute());
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GenealogyTest method testWife_definedViaRoleVariable.
@Test
public void testWife_definedViaRoleVariable() {
String queryString = "match ($r: $x) isa marriage;$r label 'wife';get $x;";
String queryString2 = "match (wife: $x) isa marriage; get;";
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
List<Answer> answers2 = query2.execute();
assertCollectionsEqual(answers2, qb.<GetQuery>parse(queryString2).execute());
List<Answer> answers = query.execute();
assertTrue(!answers.isEmpty());
assertCollectionsEqual(answers, answers2);
}
Aggregations