Search in sources :

Example 81 with QueryBuilder

use of ai.grakn.graql.QueryBuilder 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 82 with QueryBuilder

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

the class QueryValidityTest method whenQueryingForRelationWithNonExistentRoles_Throws.

@Test
public void whenQueryingForRelationWithNonExistentRoles_Throws() throws GraqlQueryException {
    QueryBuilder qb = testContext.tx().graql().infer(true);
    String queryString = "match (rola: $x, rola: $y) isa relationship; get;";
    expectedException.expect(GraqlQueryException.class);
    qb.<GetQuery>parse(queryString).execute();
}
Also used : QueryBuilder(ai.grakn.graql.QueryBuilder) Test(org.junit.Test)

Example 83 with QueryBuilder

use of ai.grakn.graql.QueryBuilder 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 84 with QueryBuilder

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

the class QueryValidityTest method whenQueryingForRelationWithNonRoleRoles_Throws.

@Test
public void whenQueryingForRelationWithNonRoleRoles_Throws() throws GraqlQueryException {
    QueryBuilder qb = testContext.tx().graql().infer(true);
    String queryString = "match (entity: $x, entity: $y) isa relationship; get;";
    expectedException.expect(GraqlQueryException.class);
    qb.<GetQuery>parse(queryString).execute();
}
Also used : QueryBuilder(ai.grakn.graql.QueryBuilder) Test(org.junit.Test)

Example 85 with QueryBuilder

use of ai.grakn.graql.QueryBuilder 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)

Aggregations

QueryBuilder (ai.grakn.graql.QueryBuilder)208 Test (org.junit.Test)202 Answer (ai.grakn.graql.admin.Answer)101 GetQuery (ai.grakn.graql.GetQuery)60 GraknTx (ai.grakn.GraknTx)51 SampleKBContext (ai.grakn.test.rule.SampleKBContext)20 EmbeddedGraknTx (ai.grakn.kb.internal.EmbeddedGraknTx)18 Concept (ai.grakn.concept.Concept)16 QueryAnswer (ai.grakn.graql.internal.query.QueryAnswer)9 Ignore (org.junit.Ignore)8 Var (ai.grakn.graql.Var)5 VarPattern (ai.grakn.graql.VarPattern)5 List (java.util.List)5 Label (ai.grakn.concept.Label)4 ReasonerAtomicQuery (ai.grakn.graql.internal.reasoner.query.ReasonerAtomicQuery)4 Sets (com.google.common.collect.Sets)4 Assert.assertEquals (org.junit.Assert.assertEquals)4 RelationshipType (ai.grakn.concept.RelationshipType)3 Graql (ai.grakn.graql.Graql)3 Graql.var (ai.grakn.graql.Graql.var)3