use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.
the class RestResultTest method testStatus.
@Test
public void testStatus() {
RestResult result = newRestResult(200);
Assert.assertEquals(200, result.status());
}
use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.
the class RestResultTest method testContentWithException.
@Test
public void testContentWithException() {
String content = "{illegal key: \"marko\"}";
RestResult result = newRestResult(200, content);
Assert.assertEquals(200, result.status());
Assert.assertEquals(content, result.content());
Assert.assertThrows(SerializeException.class, () -> {
result.readObject(Map.class);
});
}
use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.
the class RestResultTest method testContent.
@Test
public void testContent() {
String content = "{\"name\": \"marko\"}";
RestResult result = newRestResult(200, content);
Assert.assertEquals(200, result.status());
Assert.assertEquals(content, result.content());
Assert.assertEquals(ImmutableMap.of("name", "marko"), result.readObject(Map.class));
}
use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.
the class RaysAPI method get.
public List<Path> get(Object sourceId, Direction direction, String label, int depth, long degree, long capacity, long limit) {
String source = GraphAPI.formatVertexId(sourceId, false);
checkPositive(depth, "Max depth of path");
checkDegree(degree);
checkCapacity(capacity);
checkLimit(limit);
Map<String, Object> params = new LinkedHashMap<>();
params.put("source", source);
params.put("direction", direction);
params.put("label", label);
params.put("max_depth", depth);
params.put("max_degree", degree);
params.put("capacity", capacity);
params.put("limit", limit);
RestResult result = this.client.get(this.path(), params);
return result.readList(this.type(), Path.class);
}
use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.
the class SingleSourceShortestPathAPI method get.
public WeightedPaths get(Object sourceId, Direction direction, String label, String weight, long degree, long skipDegree, long capacity, long limit, boolean withVertex) {
this.client.checkApiVersion("0.51", "single source shortest path");
String source = GraphAPI.formatVertexId(sourceId, false);
E.checkNotNull(weight, "weight");
checkDegree(degree);
checkCapacity(capacity);
checkSkipDegree(skipDegree, degree, capacity);
checkLimit(limit);
Map<String, Object> params = new LinkedHashMap<>();
params.put("source", source);
params.put("direction", direction);
params.put("label", label);
params.put("weight", weight);
params.put("max_degree", degree);
params.put("skip_degree", skipDegree);
params.put("capacity", capacity);
params.put("limit", limit);
params.put("with_vertex", withVertex);
RestResult result = this.client.get(this.path(), params);
return result.readObject(WeightedPaths.class);
}
Aggregations