Search in sources :

Example 1 with Match

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

the class MatchModifierTest method testOrPatternOrderByUnselected.

@Test
public void testOrPatternOrderByUnselected() {
    Match match = qb.match(x.isa("movie"), var().rel(x).rel(y), or(y.isa("person"), y.isa("genre").val(neq("crime"))), y.has("name", n)).orderBy(n);
    assertResultsOrderedByValue(match, n, true);
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 2 with Match

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

the class MatchModifierTest method whenGettingAVarNotInQuery_Throw.

@Test
public void whenGettingAVarNotInQuery_Throw() {
    Match match = qb.match(x.isa("movie"));
    exception.expect(GraqlQueryException.class);
    exception.expectMessage(VARIABLE_NOT_IN_QUERY.getMessage(y));
    // noinspection ResultOfMethodCallIgnored
    match.get(ImmutableSet.of(y));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 3 with Match

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

the class MatchModifierTest method testOrPatternOrderByResource.

@Test
public void testOrPatternOrderByResource() {
    Match match = qb.match(x.isa("movie").has("tmdb-vote-count", var("v")), var().rel(x).rel(y), or(y.isa("person").has("name", "Marlon Brando"), y.isa("genre").has("name", "crime"))).orderBy("v", desc);
    assertThat(match, variable(x, contains(godfather, godfather, apocalypseNow)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 4 with Match

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

the class MatchModifierTest method testOrPatternDistinct.

@Test
public void testOrPatternDistinct() {
    Match match = qb.match(x.isa("movie").has("title", var("t")), var().rel(x).rel(y), or(y.isa("genre").has("name", "crime"), y.isa("person").has("name", "Marlon Brando"))).orderBy("t", desc);
    assertThat(match, variable(x, contains(heat, godfather, godfather, apocalypseNow)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 5 with Match

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

the class MatchModifierTest method testOffsetQuery.

@Test
public void testOffsetQuery() {
    Match match = qb.match(x.isa("movie").has("name", n)).orderBy(n, desc).offset(4);
    assertResultsOrderedByValue(match, n, false);
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Aggregations

Match (ai.grakn.graql.Match)103 Test (org.junit.Test)98 Var (ai.grakn.graql.Var)8 ConceptId (ai.grakn.concept.ConceptId)5 Concept (ai.grakn.concept.Concept)4 SchemaConcept (ai.grakn.concept.SchemaConcept)4 PatternAdmin (ai.grakn.graql.admin.PatternAdmin)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 AttributeType (ai.grakn.concept.AttributeType)3 Label (ai.grakn.concept.Label)3 Relationship (ai.grakn.concept.Relationship)3 Printer (ai.grakn.graql.Printer)3 QueryBuilder (ai.grakn.graql.QueryBuilder)3 Answer (ai.grakn.graql.admin.Answer)3 MatchableConcept (ai.grakn.matcher.MatchableConcept)3 Matcher (org.hamcrest.Matcher)3 RelationshipType (ai.grakn.concept.RelationshipType)2 Role (ai.grakn.concept.Role)2 Thing (ai.grakn.concept.Thing)2 GraqlQueryException (ai.grakn.exception.GraqlQueryException)2