Search in sources :

Example 76 with GetQuery

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"));
}
Also used : Answer(ai.grakn.graql.admin.Answer) GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 77 with GetQuery

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"));
}
Also used : Answer(ai.grakn.graql.admin.Answer) GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 78 with GetQuery

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());
}
Also used : Answer(ai.grakn.graql.admin.Answer) GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 79 with GetQuery

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());
}
Also used : Answer(ai.grakn.graql.admin.Answer) GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 80 with GetQuery

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);
}
Also used : Answer(ai.grakn.graql.admin.Answer) GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Aggregations

GetQuery (ai.grakn.graql.GetQuery)163 Test (org.junit.Test)161 Answer (ai.grakn.graql.admin.Answer)65 QueryBuilder (ai.grakn.graql.QueryBuilder)61 GraknTx (ai.grakn.GraknTx)51 EmbeddedGraknTx (ai.grakn.kb.internal.EmbeddedGraknTx)23 QueryAnswer (ai.grakn.graql.internal.query.QueryAnswer)14 SampleKBContext (ai.grakn.test.rule.SampleKBContext)12 Concept (ai.grakn.concept.Concept)9 List (java.util.List)8 Assert.assertEquals (org.junit.Assert.assertEquals)7 Assert.assertTrue (org.junit.Assert.assertTrue)7 Set (java.util.Set)6 Label (ai.grakn.concept.Label)5 RelationshipType (ai.grakn.concept.RelationshipType)5 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)5 ReasonerAtomicQuery (ai.grakn.graql.internal.reasoner.query.ReasonerAtomicQuery)5 Sets (com.google.common.collect.Sets)5 Collectors (java.util.stream.Collectors)5 Collectors.toSet (java.util.stream.Collectors.toSet)5