Search in sources :

Example 71 with Match

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

the class MatchTest method testRobertDeNiroNotRelatedToSelfWhenMetaRoleIsSpecified.

@Test
public void testRobertDeNiroNotRelatedToSelfWhenMetaRoleIsSpecified() {
    // This can go wrong because one role-player may use a shortcut edge and the other may not
    Match query = qb.match(var().rel("role", x).rel("actor", y).isa("has-cast"), y.has("name", "Robert de Niro"));
    assertThat(query, variable(x, containsInAnyOrder(heat, neilMcCauley)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 72 with Match

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

the class MatchTest method testAllowedToReferToNonExistentRoleplayer.

@Test
public void testAllowedToReferToNonExistentRoleplayer() {
    Match query = qb.match(var().rel("actor", var().id(ConceptId.of("999999999999999999"))));
    assertThat(query, emptyIterable());
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 73 with Match

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

the class MatchTest method testRegexQuery.

@Test
public void testRegexQuery() {
    Match query = qb.match(x.isa("genre").has("name", regex("^f.*y$")));
    assertThat(query, variable(x, containsInAnyOrder(family, fantasy)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 74 with Match

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

the class MatchTest method testSubSelf.

@Test
public void testSubSelf() {
    Match query = qb.match(label("movie").sub(x));
    assertThat(query, variable(x, containsInAnyOrder(movie, production, entity, concept)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 75 with Match

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

the class MatchTest method testQueryNoVariables.

@Test
public void testQueryNoVariables() {
    Match query = qb.match(x.isa("movie"));
    assertThat(query, allOf((Matcher) everyItem(not(hasKey(anything()))), iterableWithSize(movies.size())));
}
Also used : Matcher(org.hamcrest.Matcher) 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