Search in sources :

Example 1 with CustomizedCrosspoints

use of com.baidu.hugegraph.structure.traverser.CustomizedCrosspoints in project incubator-hugegraph-toolchain by apache.

the class CommonTraverserApiTest method testCustomizedCrosspoints.

@Test
public void testCustomizedCrosspoints() {
    Object lopId = getVertexId("software", "name", "lop");
    Object joshId = getVertexId("person", "name", "josh");
    Object rippleId = getVertexId("software", "name", "ripple");
    CrosspointsRequest.Builder builder = CrosspointsRequest.builder();
    builder.sources().ids(lopId, rippleId);
    builder.pathPatterns().steps().direction(Direction.IN).labels("created").degree(-1);
    builder.withPath(true).withVertex(true).capacity(-1).limit(-1);
    CustomizedCrosspoints customizedCrosspoints = customizedCrosspointsAPI.post(builder.build());
    List<Object> crosspoints = customizedCrosspoints.crosspoints();
    Assert.assertEquals(1, crosspoints.size());
    Assert.assertEquals(joshId, crosspoints.get(0));
    List<Path> paths = customizedCrosspoints.paths();
    Assert.assertEquals(2, paths.size());
    List<Object> path1 = ImmutableList.of(rippleId, joshId);
    List<Object> path2 = ImmutableList.of(lopId, joshId);
    List<List<Object>> expectedPaths = ImmutableList.of(path1, path2);
    Assert.assertTrue(expectedPaths.contains(paths.get(0).objects()));
    Assert.assertTrue(expectedPaths.contains(paths.get(1).objects()));
    Set<?> vertices = customizedCrosspoints.vertices().stream().map(Vertex::id).collect(Collectors.toSet());
    List<Object> expectedVids = ImmutableList.of(rippleId, joshId, lopId);
    Assert.assertTrue(expectedVids.containsAll(vertices));
}
Also used : Path(com.baidu.hugegraph.structure.graph.Path) CrosspointsRequest(com.baidu.hugegraph.structure.traverser.CrosspointsRequest) CustomizedCrosspoints(com.baidu.hugegraph.structure.traverser.CustomizedCrosspoints) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) LinkedList(java.util.LinkedList) Test(org.junit.Test) BaseApiTest(com.baidu.hugegraph.api.BaseApiTest)

Aggregations

BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)1 Path (com.baidu.hugegraph.structure.graph.Path)1 CrosspointsRequest (com.baidu.hugegraph.structure.traverser.CrosspointsRequest)1 CustomizedCrosspoints (com.baidu.hugegraph.structure.traverser.CustomizedCrosspoints)1 ImmutableList (com.google.common.collect.ImmutableList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Test (org.junit.Test)1