Search in sources :

Example 46 with GetQuery

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

the class QueryParserTest method testLongComparatorQuery.

@Test
public void testLongComparatorQuery() throws ParseException {
    GetQuery expected = match(var("x").isa("movie").has("tmdb-vote-count", lte(400))).get();
    GetQuery parsed = parse("match $x isa movie, has tmdb-vote-count <= 400; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 47 with GetQuery

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

the class QueryParserTest method testPredicateQuery2.

@Test
public void testPredicateQuery2() {
    GetQuery expected = match(var("x").isa("movie").has("title", var("t")), or(and(var("t").val(lte("Juno")), var("t").val(gte("Godfather")), var("t").val(neq("Heat"))), var("t").val("The Muppets"))).get();
    GetQuery parsed = parse("match $x isa movie, has title $t;" + "{$t val <= 'Juno'; $t val >= 'Godfather'; $t val != 'Heat';} or $t val = 'The Muppets'; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 48 with GetQuery

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

the class QueryParserTest method whenParsingDate_HandleBigYears.

@Test
public void whenParsingDate_HandleBigYears() {
    GetQuery expected = match(var("x").has("release-date", LocalDate.of(12345, 12, 25).atStartOfDay())).get();
    GetQuery parsed = parse("match $x has release-date +12345-12-25; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 49 with GetQuery

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

the class QueryParserTest method testModifierQuery.

@Test
public void testModifierQuery() {
    GetQuery expected = match(var("y").isa("movie").has("title", var("n"))).orderBy("n").limit(4).offset(2).get();
    GetQuery parsed = parse("match $y isa movie, has title $n; order by $n; limit 4; offset 2; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 50 with GetQuery

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

the class QueryParserTest method testQueryParserWithoutGraph.

@Test
public void testQueryParserWithoutGraph() {
    String queryString = "match $x isa movie; get $x;";
    GetQuery query = parse("match $x isa movie; get $x;");
    assertEquals(queryString, query.toString());
}
Also used : GetQuery(ai.grakn.graql.GetQuery) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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