Search in sources :

Example 81 with Match

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

the class MatchTest method whenQueryingForSameRoleTwice_DoNotReturnDuplicateRolePlayers.

@Test
public void whenQueryingForSameRoleTwice_DoNotReturnDuplicateRolePlayers() {
    Match query = qb.match(var().rel("cluster-of-production", x).rel("cluster-of-production", y));
    query.forEach(result -> {
        assertNotEquals(result.get(x), result.get(y));
    });
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 82 with Match

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

the class MatchTest method testNameQuery.

@Test
public void testNameQuery() {
    Match query = qb.match(x.has("title", "Godfather"));
    assertThat(query, variable(x, contains(godfather)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 83 with Match

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

the class MatchTest method whenQueryingForSuperRoleType_ReturnResults.

@Test
public void whenQueryingForSuperRoleType_ReturnResults() {
    Match query = qb.match(var().rel("role", x).rel(y));
    assertExists(query);
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 84 with Match

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

the class MatchTest method whenQueryingForSuperRelationType_ReturnResults.

@Test
public void whenQueryingForSuperRelationType_ReturnResults() {
    Match query = qb.match(var().isa(Schema.MetaSchema.RELATIONSHIP.getLabel().getValue()).rel(x).rel(y));
    assertExists(query);
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 85 with Match

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

the class MatchTest method testAllGreaterThanResources.

@Test
public void testAllGreaterThanResources() {
    Match query = qb.match(x.val(gt(y)));
    assertThat(query, iterableWithSize(greaterThan(10)));
    query.forEach(result -> {
        Comparable cx = (Comparable) result.get(x).asAttribute().getValue();
        Comparable cy = (Comparable) result.get(y).asAttribute().getValue();
        assertThat(cx, greaterThan(cy));
    });
}
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