Search in sources :

Example 66 with GetQuery

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

the class QueryValidityTest method whenQueryingForIllegalResource_emptyResultReturned.

@Test
public void whenQueryingForIllegalResource_emptyResultReturned() {
    QueryBuilder qb = testContext.tx().graql().infer(true);
    String queryString = "match $x has name $n; $x isa binary; get;";
    assertThat(qb.<GetQuery>parse(queryString).execute(), empty());
}
Also used : GetQuery(ai.grakn.graql.GetQuery) QueryBuilder(ai.grakn.graql.QueryBuilder) Test(org.junit.Test)

Example 67 with GetQuery

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

the class QueryValidityTest method whenQueryingForInexistentResourceId_emptyResultReturned.

@Test
public void whenQueryingForInexistentResourceId_emptyResultReturned() {
    QueryBuilder qb = testContext.tx().graql().infer(true);
    String queryString = "match $x has name $y; $x id 'V123'; get;";
    String queryString2 = "match $x has name $y; $y id 'V123'; get;";
    String queryString3 = "match $x has name $y via $r; $r id 'V123'; get;";
    assertThat(qb.<GetQuery>parse(queryString).execute(), empty());
    assertThat(qb.<GetQuery>parse(queryString2).execute(), empty());
    assertThat(qb.<GetQuery>parse(queryString3).execute(), empty());
}
Also used : GetQuery(ai.grakn.graql.GetQuery) QueryBuilder(ai.grakn.graql.QueryBuilder) Test(org.junit.Test)

Example 68 with GetQuery

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

the class QueryValidityTest method whenQueryingForInexistentEntityTypeId_emptyResultReturned.

@Test
public void whenQueryingForInexistentEntityTypeId_emptyResultReturned() {
    QueryBuilder qb = testContext.tx().graql().infer(true);
    String queryString = "match $x isa $type; $type id 'V123'; get;";
    assertThat(qb.<GetQuery>parse(queryString).execute(), empty());
}
Also used : GetQuery(ai.grakn.graql.GetQuery) QueryBuilder(ai.grakn.graql.QueryBuilder) Test(org.junit.Test)

Example 69 with GetQuery

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

Example 70 with GetQuery

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

the class GenealogyTest method testGrandParentship.

@Test
public void testGrandParentship() {
    String queryString = "match " + "(grandchild: $x); (granddaughter: $x);$x has gender $g; get;";
    GetQuery query = iqb.parse(queryString);
    List<Answer> answers = query.execute();
    assertEquals(answers.size(), 18);
    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)

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