Search in sources :

Example 76 with Match

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

the class MatchTest method whenQueryingForXSubY_ReturnOnlyTypes.

@Test
public void whenQueryingForXSubY_ReturnOnlyTypes() {
    Match query = qb.match(x.sub(y));
    assertThat(query, variable(x, everyItem(not(isInstance()))));
    assertThat(query, variable(y, everyItem(not(isInstance()))));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 77 with Match

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

the class MatchTest method testMatchKey.

@Test
public void testMatchKey() {
    Match query = qb.match(x.key("name"));
    assertThat(query, variable(x, contains(genre)));
}
Also used : Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 78 with Match

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

the class MatchTest method testSchemaQuery.

@Test
public void testSchemaQuery() {
    Var type = var("type");
    Match query = qb.match(type.plays("character-being-played"));
    assertThat(query, variable(type, containsInAnyOrder(character, person)));
}
Also used : Var(ai.grakn.graql.Var) Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 79 with Match

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

the class MatchTest method whenQueryingForSameRoleTwiceWhenItIsPlayedOnce_ReturnNoResults.

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

Example 80 with Match

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

the class MatchTest method testMatchAllDistinctPairsOfACertainType.

@Test
public void testMatchAllDistinctPairsOfACertainType() {
    int numConcepts = (int) qb.match(x.isa("movie")).stream().count();
    Match pairs = qb.match(x.isa("movie"), y.isa("movie"), x.neq(y));
    assertThat(pairs, iterableWithSize(numConcepts * (numConcepts - 1)));
}
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