Search in sources :

Example 41 with Match

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

the class MatchTest method testRoleQuery.

@Test
public void testRoleQuery() {
    Match query = qb.match(var().rel("actor", x).rel(y), y.has("title", "Apocalypse Now"));
    assertThat(query, variable(x, containsInAnyOrder(marlonBrando, martinSheen)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 42 with Match

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

the class MatchTest method testMatchRuleRightHandSide.

@Test
public void testMatchRuleRightHandSide() {
    Match query = qb.match(x.when(qb.parser().parsePattern("$x id 'expect-when'")).then(qb.parser().parsePattern("$x id 'expect-then'")));
    expectedException.expect(UnsupportedOperationException.class);
    expectedException.expectMessage(MATCH_INVALID.getMessage("when"));
    query.forEach(r -> {
    });
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 43 with Match

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

the class MatchTest method testGlobalPredicateQuery.

@Test
public void testGlobalPredicateQuery() {
    Match query = qb.match(x.val(gt(500L)), x.val(lt(1000000L)));
    assertThat(query, variable(x, contains(both(hasValue(1000L)).and(hasType(tmdbVoteCount)))));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 44 with Match

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

the class MatchTest method testTypeLabelQuery.

@Test
public void testTypeLabelQuery() {
    Match query = qb.match(or(x.label("character"), x.label("person")));
    assertThat(query, variable(x, containsInAnyOrder(character, person)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 45 with Match

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

the class MatchTest method testDatePredicateQuery.

@Test
public void testDatePredicateQuery() throws ParseException {
    Match query = qb.match(x.has("release-date", gte(LocalDateTime.of(1984, 6, 23, 12, 34, 56))));
    assertThat(query, variable(x, containsInAnyOrder(spy, theMuppets, chineseCoffee)));
}
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