Search in sources :

Example 1 with PathQuery

use of ai.grakn.graql.analytics.PathQuery in project grakn by graknlabs.

the class GraqlTest method testPath.

@Test
public void testPath() throws InvalidKBException {
    addSchemaAndEntities();
    try (GraknTx graph = session.open(GraknTxType.WRITE)) {
        PathQuery query = graph.graql().parse("compute path from '" + entityId1 + "' to '" + entityId2 + "';");
        Optional<List<Concept>> path = query.execute();
        List<String> result = path.get().stream().map(Concept::getId).map(ConceptId::getValue).collect(Collectors.toList());
        List<String> expected = Lists.newArrayList(entityId1, relationId12, entityId2);
        assertEquals(expected, result);
    }
}
Also used : Concept(ai.grakn.concept.Concept) GraknTx(ai.grakn.GraknTx) PathQuery(ai.grakn.graql.analytics.PathQuery) List(java.util.List) Test(org.junit.Test)

Aggregations

GraknTx (ai.grakn.GraknTx)1 Concept (ai.grakn.concept.Concept)1 PathQuery (ai.grakn.graql.analytics.PathQuery)1 List (java.util.List)1 Test (org.junit.Test)1