Examples of RestRequest


Examples of org.elasticsearch.thrift.RestRequest

        if (transport != null) transport.close();
    }

    @Test
    public void testSimpleApis() throws Exception {
        RestRequest request = new RestRequest(Method.POST, "/test/type1/1");
        request.setBody(ByteBuffer.wrap(XContentFactory.jsonBuilder().startObject()
                .field("field", "value")
                .endObject().bytes().copyBytesArray().array()));
        RestResponse response = client.execute(request);
        Map<String, Object> map = parseBody(response);
        assertThat(response.getStatus(), equalTo(Status.CREATED));
        assertThat(map.get("_index").toString(), equalTo("test"));
        assertThat(map.get("_type").toString(), equalTo("type1"));
        assertThat(map.get("_id").toString(), equalTo("1"));

        request = new RestRequest(Method.GET, "/test/type1/1");
        response = client.execute(request);
        map = parseBody(response);
        assertThat(response.getStatus(), equalTo(Status.OK));
        assertThat(map.get("_index").toString(), equalTo("test"));
        assertThat(map.get("_type").toString(), equalTo("type1"));
        assertThat(map.get("_id").toString(), equalTo("1"));
        assertThat(map.get("_source"), notNullValue());
        assertThat(map.get("_source"), instanceOf(Map.class));
        assertThat(((Map<String, String>)map.get("_source")).get("field"), is("value"));

        request = new RestRequest(Method.GET, "/_cluster/health");
        response = client.execute(request);
        assertThat(response.getStatus(), equalTo(Status.OK));

        request = new RestRequest(Method.GET, "/bogusindex");
        response = client.execute(request);
        assertThat(response.getStatus(), equalTo(Status.NOT_FOUND));
    }
View Full Code Here

Examples of smartrics.rest.client.RestRequest

     * Builds a empty rest request.
     *
     * @return the rest request.
     */
    public RestRequest buildRestRequest() {
        return new RestRequest();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.