Search in sources :

Example 1 with IdProperty

use of ai.grakn.graql.internal.pattern.property.IdProperty in project grakn by graknlabs.

the class GraqlTraversalTest method testAllTraversalsSimpleQuery.

@Test
public void testAllTraversalsSimpleQuery() {
    IdProperty titanicId = IdProperty.of(ConceptId.of("Titanic"));
    IdProperty movieId = IdProperty.of(ConceptId.of("movie"));
    SubProperty subProperty = SubProperty.of(Patterns.varPattern(y, ImmutableSet.of(movieId)));
    VarPattern pattern = Patterns.varPattern(x, ImmutableSet.of(titanicId, subProperty));
    Set<GraqlTraversal> traversals = allGraqlTraversals(pattern).collect(toSet());
    assertEquals(12, traversals.size());
    Fragment xId = id(titanicId, x, ConceptId.of("Titanic"));
    Fragment yId = id(movieId, y, ConceptId.of("movie"));
    Fragment xSubY = outSub(subProperty, x, y);
    Fragment ySubX = inSub(subProperty, y, x);
    Set<GraqlTraversal> expected = ImmutableSet.of(traversal(xId, xSubY, yId), traversal(xId, ySubX, yId), traversal(xId, yId, xSubY), traversal(xId, yId, ySubX), traversal(xSubY, xId, yId), traversal(xSubY, yId, xId), traversal(ySubX, xId, yId), traversal(ySubX, yId, xId), traversal(yId, xId, xSubY), traversal(yId, xId, ySubX), traversal(yId, xSubY, xId), traversal(yId, ySubX, xId));
    assertEquals(expected, traversals);
}
Also used : IdProperty(ai.grakn.graql.internal.pattern.property.IdProperty) SubProperty(ai.grakn.graql.internal.pattern.property.SubProperty) VarPattern(ai.grakn.graql.VarPattern) Fragment(ai.grakn.graql.internal.gremlin.fragment.Fragment) Test(org.junit.Test)

Aggregations

VarPattern (ai.grakn.graql.VarPattern)1 Fragment (ai.grakn.graql.internal.gremlin.fragment.Fragment)1 IdProperty (ai.grakn.graql.internal.pattern.property.IdProperty)1 SubProperty (ai.grakn.graql.internal.pattern.property.SubProperty)1 Test (org.junit.Test)1