Search in sources :

Example 1 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.

the class RestClientTest method testPostHttpsWithAllParams.

@Test
public void testPostHttpsWithAllParams() {
    String trustStoreFile = "src/test/resources/cacerts.jks";
    String trustStorePassword = "changeit";
    RestClient client = new RestClientImpl("/test", "user", "", 1000, 10, 5, trustStoreFile, trustStorePassword, 200);
    RestResult restResult = client.post("path", "body");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 2 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.

the class RestClientTest method testGet.

@Test
public void testGet() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    RestResult restResult = client.get("path");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 3 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.

the class RestClientTest method testPostWithAllParams.

@Test
public void testPostWithAllParams() {
    RestClient client = new RestClientImpl("/test", "user", "", 1000, 10, 5, 200);
    RestResult restResult = client.post("path", "body");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 4 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.

the class RestClientTest method testPut.

@Test
public void testPut() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    RestResult restResult = client.put("path", "id1", "body");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 5 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project hugegraph-common by hugegraph.

the class RestClientTest method testPostWithHeaderAndContent.

@Test
public void testPostWithHeaderAndContent() {
    MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
    headers.add("key1", "value1-1");
    headers.add("key1", "value1-2");
    headers.add("Content-Encoding", "gzip");
    String content = "{\"names\": [\"marko\", \"josh\", \"lop\"]}";
    RestClient client = new RestClientImpl("/test", 1000, 200, headers, content);
    RestResult restResult = client.post("path", "body");
    Assert.assertEquals(200, restResult.status());
    Assert.assertEquals(headers, restResult.headers());
    Assert.assertEquals(content, restResult.content());
    Assert.assertEquals(ImmutableList.of("marko", "josh", "lop"), restResult.readList("names", String.class));
}
Also used : MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

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