Search in sources :

Example 91 with GetQuery

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

the class QueryParserTest method testOrQuery.

@Test
public void testOrQuery() {
    GetQuery expected = match(var("x").isa("movie"), or(and(var("y").isa("genre").val("drama"), var().rel("x").rel("y")), var("x").val("The Muppets"))).get();
    GetQuery parsed = parse("match $x isa movie; { $y isa genre val 'drama'; ($x, $y); } or $x val 'The Muppets'; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 92 with GetQuery

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

the class QueryParserTest method testMatchDataTypeQuery.

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

Example 93 with GetQuery

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

the class QueryParserTest method whenParsingDate_HandleTime.

@Test
public void whenParsingDate_HandleTime() {
    GetQuery expected = match(var("x").has("release-date", LocalDateTime.of(1000, 11, 12, 13, 14, 15))).get();
    GetQuery parsed = parse("match $x has release-date 1000-11-12T13:14:15; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 94 with GetQuery

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

the class QueryParserTest method testHasVariable.

@Test
public void testHasVariable() {
    GetQuery expected = match(var().has("title", "Godfather").has("tmdb-vote-count", var("x"))).get();
    GetQuery parsed = parse("match has title 'Godfather' has tmdb-vote-count $x; get;");
    assertEquals(expected, parsed);
}
Also used : GetQuery(ai.grakn.graql.GetQuery) Test(org.junit.Test)

Example 95 with GetQuery

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

the class QueryParserTest method testRelationQuery.

@Test
public void testRelationQuery() {
    GetQuery expected = match(var("brando").val("Marl B").isa("person"), var().rel("actor", "brando").rel("char").rel("production-with-cast", "prod")).get("char", "prod");
    GetQuery parsed = parse("match\n" + "$brando val \"Marl B\" isa person;\n" + "(actor: $brando, $char, production-with-cast: $prod);\n" + "get $char, $prod;");
    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