Search in sources :

Example 86 with GetQuery

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

the class QueryToStringTest method testComplexQueryToString.

@Test
public void testComplexQueryToString() {
    GetQuery query = qb.match(var("x").isa("movie"), var().rel("x").rel("y"), or(var("y").isa("person"), var("y").isa("genre").val(neq("crime"))), var("y").has("name", var("n"))).orderBy("n").limit(8).offset(4).get("x", "y");
    assertEquivalent(query, query.toString());
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 87 with GetQuery

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

the class QueryParserTest method whenParsingDateKeyword_ParseAsTheCorrectDataType.

@Test
public void whenParsingDateKeyword_ParseAsTheCorrectDataType() {
    GetQuery expected = match(var("x").datatype(AttributeType.DataType.DATE)).get();
    GetQuery parsed = parse("match $x datatype date; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 88 with GetQuery

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

the class QueryParserTest method testSchemaQuery.

@Test
public void testSchemaQuery() {
    GetQuery expected = match(var("x").plays("actor")).orderBy("x").get();
    GetQuery parsed = parse("match $x plays actor; order by $x asc; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 89 with GetQuery

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

the class QueryParserTest method testRegexResourceType.

@Test
public void testRegexResourceType() {
    GetQuery expected = match(var("x").regex("(fe)?male")).get();
    GetQuery parsed = parse("match $x regex /(fe)?male/; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 90 with GetQuery

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

the class QueryParserTest method testOrderQuery.

@Test
public void testOrderQuery() {
    GetQuery expected = match(var("x").isa("movie").has("release-date", var("r"))).orderBy("r", desc).get();
    GetQuery parsed = parse("match $x isa movie, has release-date $r; order by $r desc; get;");
    assertEquals(expected, parsed);
}
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