use of com.baidu.hugegraph.structure.traverser.TemplatePathsRequest in project incubator-hugegraph-toolchain by apache.
the class TemplatePathsApiTest method testTemplatePathsWithLimit.
@Test
public void testTemplatePathsWithLimit() {
TemplatePathsRequest.Builder builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("link").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("link").maxTimes(3);
builder.steps().direction(Direction.IN).labels("link").maxTimes(3);
TemplatePathsRequest request = builder.build();
PathsWithVertices pathsWithVertices = templatePathsAPI.post(request);
List<PathsWithVertices.Paths> paths = pathsWithVertices.paths();
Assert.assertEquals(3, paths.size());
List<List<Object>> expected = ImmutableList.of(ImmutableList.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), ImmutableList.of(1, 11, 12, 13, 14, 15, 10), ImmutableList.of(1, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("link").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("link").maxTimes(3);
builder.steps().direction(Direction.IN).labels("link").maxTimes(3);
builder.limit(2);
request = builder.build();
pathsWithVertices = templatePathsAPI.post(request);
paths = pathsWithVertices.paths();
Assert.assertEquals(2, paths.size());
expected = ImmutableList.of(ImmutableList.of(1, 16, 17, 10), ImmutableList.of(1, 11, 12, 13, 14, 15, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
}
Aggregations