use of com.baidu.hugegraph.structure.traverser.PathsWithVertices in project incubator-hugegraph-toolchain by apache.
the class PathsApiTest method testPathsWithLimit.
@Test
public void testPathsWithLimit() {
Object markoId = getVertexId("person", "name", "marko");
Object rippleId = getVertexId("software", "name", "ripple");
Object joshId = getVertexId("person", "name", "josh");
Object lopId = getVertexId("software", "name", "lop");
PathsRequest.Builder builder = PathsRequest.builder();
builder.sources().ids(markoId);
builder.targets().ids(rippleId);
builder.step().direction(Direction.BOTH);
builder.maxDepth(3);
PathsRequest request = builder.build();
PathsWithVertices pathsWithVertices = pathsAPI.post(request);
List<PathsWithVertices.Paths> paths = pathsWithVertices.paths();
Assert.assertEquals(2, paths.size());
List<List<Object>> expected = ImmutableList.of(ImmutableList.of(markoId, lopId, joshId, rippleId), ImmutableList.of(markoId, joshId, rippleId));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
builder = PathsRequest.builder();
builder.sources().ids(markoId);
builder.targets().ids(rippleId);
builder.step().direction(Direction.BOTH);
builder.limit(1);
builder.maxDepth(3);
request = builder.build();
pathsWithVertices = pathsAPI.post(request);
paths = pathsWithVertices.paths();
Assert.assertEquals(1, paths.size());
expected = ImmutableList.of(ImmutableList.of(markoId, joshId, rippleId));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
}
Aggregations