Search in sources :

Example 61 with Match

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

the class MatchTest method testMatchAll.

@Test
public void testMatchAll() {
    Match query = qb.match(x);
    // Make sure there a reasonable number of results
    assertThat(query, iterableWithSize(greaterThan(10)));
    // Make sure results never contain shards
    assertThat(query, variable(x, everyItem(not(isShard()))));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 62 with Match

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

the class MatchTest method whenQueryingForRole_ResultContainsAllValidRoles.

@Test
public void whenQueryingForRole_ResultContainsAllValidRoles() {
    // TODO: reasoner is not able to decompose and parse it correctly
    Match query = qb.infer(false).match(var().rel(x, var().has("name", "Michael Corleone")));
    assertThat(query, variable(x, containsInAnyOrder(role("role"), role("character-being-played"), role("@has-name-owner"))));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 63 with Match

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

the class MatchTest method testRelatedToSelf.

@Test
public void testRelatedToSelf() {
    Match query = qb.match(var().rel(x).rel(x).rel(x));
    assertThat(query, emptyIterable());
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 64 with Match

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

the class MatchTest method testPredicateQuery2.

@Test
public void testPredicateQuery2() {
    Match query = qb.match(x.isa("movie").has("title", t), or(and(t.val(lte("Juno")), t.val(gte("Godfather")), t.val(neq("Heat"))), t.val("The Muppets")));
    assertThat(query, variable(x, containsInAnyOrder(hocusPocus, godfather, theMuppets)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 65 with Match

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

the class MatchTest method testIsResource.

@Test
public void testIsResource() {
    Match query = qb.match(x.isa(Schema.MetaSchema.ATTRIBUTE.getLabel().getValue())).limit(10);
    assertThat(query, iterableWithSize(10));
    assertThat(query, variable(x, everyItem(hasType(resource))));
}
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