use of com.baidu.hugegraph.structure.traverser.Kout in project incubator-hugegraph-toolchain by apache.
the class KoutApiTest method testKoutPostWithProperties.
@Test
public void testKoutPostWithProperties() {
Object markoId = getVertexId("person", "name", "marko");
Object rippleId = getVertexId("software", "name", "ripple");
Object joshId = getVertexId("person", "name", "josh");
Object lopId = getVertexId("software", "name", "lop");
Object peterId = getVertexId("person", "name", "peter");
KoutRequest.Builder builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH).properties("date", "P.gt(\"2014-01-01 00:00:00\")");
builder.maxDepth(1);
KoutRequest request = builder.build();
Kout koutResult = koutAPI.post(request);
Assert.assertEquals(1, koutResult.size());
Set<Object> expected = ImmutableSet.of(lopId);
Assert.assertEquals(expected, koutResult.ids());
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH).properties("date", "P.gt(\"2014-01-01 00:00:00\")");
builder.maxDepth(2);
request = builder.build();
koutResult = koutAPI.post(request);
Assert.assertEquals(2, koutResult.size());
expected = ImmutableSet.of(peterId, joshId);
Assert.assertEquals(expected, koutResult.ids());
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH).properties("date", "P.gt(\"2014-01-01 00:00:00\")");
builder.maxDepth(3);
request = builder.build();
koutResult = koutAPI.post(request);
Assert.assertEquals(1, koutResult.size());
expected = ImmutableSet.of(rippleId);
Assert.assertEquals(expected, koutResult.ids());
}
use of com.baidu.hugegraph.structure.traverser.Kout in project incubator-hugegraph-toolchain by apache.
the class KoutApiTest method testKoutPostWithCountOnly.
@Test
public void testKoutPostWithCountOnly() {
Object markoId = getVertexId("person", "name", "marko");
KoutRequest.Builder builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH);
builder.maxDepth(1);
builder.countOnly(true);
KoutRequest request = builder.build();
Kout koutResult = koutAPI.post(request);
Assert.assertEquals(3, koutResult.size());
Assert.assertTrue(koutResult.ids().isEmpty());
Assert.assertTrue(koutResult.paths().isEmpty());
Assert.assertTrue(koutResult.vertices().isEmpty());
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH);
builder.maxDepth(2);
builder.countOnly(true);
request = builder.build();
koutResult = koutAPI.post(request);
Assert.assertEquals(2, koutResult.size());
Assert.assertTrue(koutResult.ids().isEmpty());
Assert.assertTrue(koutResult.paths().isEmpty());
Assert.assertTrue(koutResult.vertices().isEmpty());
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH);
builder.maxDepth(1);
builder.countOnly(true);
builder.withPath(true);
KoutRequest.Builder finalBuilder = builder;
Assert.assertThrows(IllegalArgumentException.class, () -> {
finalBuilder.build();
});
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH);
builder.maxDepth(1);
builder.countOnly(true);
builder.withVertex(true);
KoutRequest.Builder finalBuilder1 = builder;
Assert.assertThrows(IllegalArgumentException.class, () -> {
finalBuilder1.build();
});
}
use of com.baidu.hugegraph.structure.traverser.Kout in project incubator-hugegraph-toolchain by apache.
the class KoutApiTest method testKoutPostWithDirection.
@Test
public void testKoutPostWithDirection() {
Object markoId = getVertexId("person", "name", "marko");
Object rippleId = getVertexId("software", "name", "ripple");
Object joshId = getVertexId("person", "name", "josh");
Object lopId = getVertexId("software", "name", "lop");
Object vadasId = getVertexId("person", "name", "vadas");
KoutRequest.Builder builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.OUT);
builder.maxDepth(1);
KoutRequest request = builder.build();
Kout koutResult = koutAPI.post(request);
Assert.assertEquals(3, koutResult.size());
Set<Object> expected = ImmutableSet.of(vadasId, lopId, joshId);
Assert.assertEquals(expected, koutResult.ids());
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.OUT);
builder.maxDepth(2);
request = builder.build();
koutResult = koutAPI.post(request);
Assert.assertEquals(1, koutResult.size());
expected = ImmutableSet.of(rippleId);
Assert.assertEquals(expected, koutResult.ids());
}
use of com.baidu.hugegraph.structure.traverser.Kout in project incubator-hugegraph-toolchain by apache.
the class KoutApiTest method testKoutPost.
@Test
public void testKoutPost() {
Object markoId = getVertexId("person", "name", "marko");
Object rippleId = getVertexId("software", "name", "ripple");
Object joshId = getVertexId("person", "name", "josh");
Object lopId = getVertexId("software", "name", "lop");
Object vadasId = getVertexId("person", "name", "vadas");
Object peterId = getVertexId("person", "name", "peter");
KoutRequest.Builder builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH);
builder.maxDepth(1);
KoutRequest request = builder.build();
Kout koutResult = koutAPI.post(request);
Assert.assertEquals(3, koutResult.size());
Set<Object> expected = ImmutableSet.of(vadasId, lopId, joshId);
Assert.assertEquals(expected, koutResult.ids());
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH);
builder.maxDepth(2);
request = builder.build();
koutResult = koutAPI.post(request);
Assert.assertEquals(2, koutResult.size());
expected = ImmutableSet.of(peterId, rippleId);
Assert.assertEquals(expected, koutResult.ids());
}
use of com.baidu.hugegraph.structure.traverser.Kout in project incubator-hugegraph-toolchain by apache.
the class KoutApiTest method testKoutPostWithMultiLabels.
@Test
public void testKoutPostWithMultiLabels() {
Object markoId = getVertexId("person", "name", "marko");
Object joshId = getVertexId("person", "name", "josh");
Object lopId = getVertexId("software", "name", "lop");
Object vadasId = getVertexId("person", "name", "vadas");
Object peterId = getVertexId("person", "name", "peter");
Object rippleId = getVertexId("software", "name", "ripple");
KoutRequest.Builder builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH).labels("knows").labels("created");
builder.maxDepth(1);
KoutRequest request = builder.build();
Kout koutResult = koutAPI.post(request);
Assert.assertEquals(3, koutResult.size());
Set<Object> expected = ImmutableSet.of(vadasId, joshId, lopId);
Assert.assertEquals(expected, koutResult.ids());
builder = KoutRequest.builder();
builder.source(markoId);
builder.step().direction(Direction.BOTH).labels("knows").labels("created");
builder.maxDepth(2);
request = builder.build();
koutResult = koutAPI.post(request);
Assert.assertEquals(2, koutResult.size());
expected = ImmutableSet.of(peterId, rippleId);
Assert.assertEquals(expected, koutResult.ids());
}
Aggregations