Search in sources :

Example 1 with HttpResponse

use of io.confluent.ksql.api.client.Client.HttpResponse in project ksql by confluentinc.

the class ClientTest method setSessionVariablesWithHttpRequest.

@Test
public void setSessionVariablesWithHttpRequest() throws Exception {
    javaClient.define("some-var", "var-value");
    HttpResponse response = javaClient.buildRequest("POST", "/ksql").payload("ksql", "CREATE STREAM FOO AS CONCAT(A, `wow;`) FROM `BAR`;").propertiesKey("streamsProperties").property("auto.offset.reset", "earliest").send().get();
    assertThat(response.status(), is(200));
    assertThat(testEndpoints.getLastSessionVariables(), is(new JsonObject().put("some-var", "var-value")));
    assertThat(testEndpoints.getLastProperties(), is(new JsonObject().put("auto.offset.reset", "earliest")));
}
Also used : HttpResponse(io.confluent.ksql.api.client.Client.HttpResponse) JsonObject(io.vertx.core.json.JsonObject) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Example 2 with HttpResponse

use of io.confluent.ksql.api.client.Client.HttpResponse in project ksql by confluentinc.

the class ClientTest method clientShouldMakeHttpRequests.

@Test
public void clientShouldMakeHttpRequests() throws Exception {
    HttpResponse response = javaClient.buildRequest("GET", "/info").send().get();
    assertThat(response.status(), is(200));
    Map<String, Map<String, Object>> info = response.bodyAsMap();
    Map<String, Object> serverInfo = info.get("KsqlServerInfo");
    assertThat(serverInfo.get("version"), is(AppInfo.getVersion()));
    assertThat(serverInfo.get("ksqlServiceId"), is("ksql-service-id"));
    assertThat(serverInfo.get("kafkaClusterId"), is("kafka-cluster-id"));
}
Also used : HttpResponse(io.confluent.ksql.api.client.Client.HttpResponse) JsonObject(io.vertx.core.json.JsonObject) Matchers.containsString(org.hamcrest.Matchers.containsString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Example 3 with HttpResponse

use of io.confluent.ksql.api.client.Client.HttpResponse in project ksql by confluentinc.

the class ClientIntegrationTest method shouldExecutePlainHttpRequests.

@Test
public void shouldExecutePlainHttpRequests() throws Exception {
    final HttpResponse response = client.buildRequest("GET", "/info").send().get();
    assertThat(response.status(), is(200));
    final Map<String, Map<String, Object>> info = response.bodyAsMap();
    final ServerInfo serverInfo = client.serverInfo().get();
    final Map<String, Object> innerMap = info.get("KsqlServerInfo");
    assertThat(innerMap.get("version"), is(serverInfo.getServerVersion()));
    assertThat(innerMap.get("ksqlServiceId"), is(serverInfo.getKsqlServiceId()));
    assertThat(innerMap.get("kafkaClusterId"), is(serverInfo.getKafkaClusterId()));
    assertThat(innerMap.get("serverStatus"), is("RUNNING"));
}
Also used : ServerInfo(io.confluent.ksql.api.client.ServerInfo) HttpResponse(io.confluent.ksql.api.client.Client.HttpResponse) JsonObject(io.vertx.core.json.JsonObject) KsqlObject(io.confluent.ksql.api.client.KsqlObject) Matchers.containsString(org.hamcrest.Matchers.containsString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 4 with HttpResponse

use of io.confluent.ksql.api.client.Client.HttpResponse in project ksql by confluentinc.

the class ClientTest method clientShouldReturn404Responses.

@Test
public void clientShouldReturn404Responses() throws Exception {
    HttpResponse response = javaClient.buildRequest("GET", "/abc").send().get();
    assertThat(response.status(), is(404));
}
Also used : HttpResponse(io.confluent.ksql.api.client.Client.HttpResponse) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Aggregations

HttpResponse (io.confluent.ksql.api.client.Client.HttpResponse)4 Test (org.junit.Test)4 BaseApiTest (io.confluent.ksql.api.BaseApiTest)3 JsonObject (io.vertx.core.json.JsonObject)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 IntegrationTest (io.confluent.common.utils.IntegrationTest)1 KsqlObject (io.confluent.ksql.api.client.KsqlObject)1 ServerInfo (io.confluent.ksql.api.client.ServerInfo)1