Search in sources :

Example 21 with RestClient

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

the class RestClientTest method testDeleteWithParams.

@Test
public void testDeleteWithParams() {
    RestClient client = new RestClientImpl("/test", 1000, 204);
    Map<String, Object> params = ImmutableMap.of("param1", "value1");
    RestResult restResult = client.delete("path", params);
    Assert.assertEquals(204, 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 22 with RestClient

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

the class RestClientTest method testDeleteWithException.

@Test
public void testDeleteWithException() {
    RestClient client = new RestClientImpl("/test", 1000, 400);
    Assert.assertThrows(ClientException.class, () -> {
        client.delete("path", "id1");
    });
}
Also used : AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 23 with RestClient

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

the class RestClientTest method testPostWithException.

@Test
public void testPostWithException() {
    RestClient client = new RestClientImpl("/test", 1000, 400);
    Assert.assertThrows(ClientException.class, () -> {
        client.post("path", "body");
    });
}
Also used : AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 24 with RestClient

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

the class RestClientTest method testGetWithParams.

@Test
public void testGetWithParams() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    Map<String, Object> params = new HashMap<>();
    params.put("key1", ImmutableList.of("value1-1", "value1-2"));
    params.put("key2", "value2");
    RestResult restResult = client.get("path", params);
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) HashMap(java.util.HashMap) MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Aggregations

AbstractRestClient (com.baidu.hugegraph.rest.AbstractRestClient)24 RestClient (com.baidu.hugegraph.rest.RestClient)24 Test (org.junit.Test)24 RestResult (com.baidu.hugegraph.rest.RestResult)19 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)3 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)2 HashMap (java.util.HashMap)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 HttpClientConnection (org.apache.http.HttpClientConnection)1 HttpRoute (org.apache.http.conn.routing.HttpRoute)1 PoolStats (org.apache.http.pool.PoolStats)1