Search in sources :

Example 81 with GetQuery

use of ai.grakn.graql.GetQuery in project grakn by graknlabs.

the class GenealogyTest method testMotherInLaw.

@Test
public void testMotherInLaw() {
    String queryString = "match (mother-in-law: $x);$x has gender $g; get;";
    String queryString2 = "match (parent-in-law: $x, child-in-law: $y) isa in-laws;$x has gender $g;$g val 'female'; get $x, $g;";
    GetQuery query = iqb.parse(queryString);
    GetQuery query2 = iqb.parse(queryString2);
    List<Answer> answers = query.execute();
    List<Answer> answers2 = query2.execute();
    assertEquals(answers.size(), 8);
    assertCollectionsEqual(answers, answers2);
    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 82 with GetQuery

use of ai.grakn.graql.GetQuery in project grakn by graknlabs.

the class GenealogyTest method testMarriage_definedViaTypeAndRelationVariable.

@Test
public void testMarriage_definedViaTypeAndRelationVariable() {
    String queryString = "match $x isa marriage; get;";
    String queryString2 = "match $x($x1, $x2) isa marriage;get $x;";
    GetQuery query = iqb.parse(queryString);
    GetQuery query2 = iqb.parse(queryString2);
    // requery
    String qs = "match ($x, $y) isa marriage; ($y, $z) isa marriage; get;";
    iqb.parse(qs).execute();
    List<Answer> answers = query.execute();
    assertEquals(answers.size(), 66);
    List<Answer> answers2 = query2.execute();
    assertCollectionsEqual(answers, answers2);
    assertEquals(answers2.size(), 66);
}
Also used : Answer(ai.grakn.graql.admin.Answer) GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 83 with GetQuery

use of ai.grakn.graql.GetQuery in project grakn by graknlabs.

the class GenealogyTest method testMother.

@Test
public void testMother() {
    String queryString = "match (mother: $x); get;";
    GetQuery query = iqb.parse(queryString);
    List<Answer> answers = query.execute();
    assertEquals(answers.size(), 9);
    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 84 with GetQuery

use of ai.grakn.graql.GetQuery in project grakn by graknlabs.

the class GenealogyTest method testChild.

@Test
public void testChild() {
    String queryString = "match (child: $x); get;";
    GetQuery query = iqb.parse(queryString);
    List<Answer> answers = query.execute();
    assertEquals(answers.size(), 38);
    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 85 with GetQuery

use of ai.grakn.graql.GetQuery in project grakn by graknlabs.

the class QueryToStringTest method testQueryToStringWithReservedKeywords.

@Test
public void testQueryToStringWithReservedKeywords() {
    GetQuery query = qb.match(var("x").isa("isa")).get();
    assertEquals("match $x isa \"isa\"; get $x;", query.toString());
}
Also used : 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