Search in sources :

Example 11 with RestResult

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());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) Test(org.junit.Test)

Example 12 with RestResult

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);
    });
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) Test(org.junit.Test)

Example 13 with RestResult

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));
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) MultivaluedMap(jakarta.ws.rs.core.MultivaluedMap) ImmutableMultivaluedMap(org.glassfish.jersey.internal.util.collection.ImmutableMultivaluedMap) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.junit.Test)

Example 14 with RestResult

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);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) LinkedHashMap(java.util.LinkedHashMap)

Example 15 with RestResult

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);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

RestResult (com.baidu.hugegraph.rest.RestResult)132 Test (org.junit.Test)44 LinkedHashMap (java.util.LinkedHashMap)23 AbstractRestClient (com.baidu.hugegraph.rest.AbstractRestClient)19 RestClient (com.baidu.hugegraph.rest.RestClient)19 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)12 Response (com.baidu.hugegraph.structure.gremlin.Response)6 Result (com.baidu.hugegraph.structure.gremlin.Result)6 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)6 Edge (com.baidu.hugegraph.structure.graph.Edge)5 Vertex (com.baidu.hugegraph.structure.graph.Vertex)5 Map (java.util.Map)5 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)4 InvalidResponseException (com.baidu.hugegraph.exception.InvalidResponseException)3 NotSupportException (com.baidu.hugegraph.exception.NotSupportException)3 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)3 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)3 ArrayList (java.util.ArrayList)3 NotAllCreatedException (com.baidu.hugegraph.exception.NotAllCreatedException)2 Project (com.baidu.hugegraph.structure.auth.Project)2