Search in sources :

Example 21 with EndpointResponse

use of io.confluent.ksql.rest.EndpointResponse in project ksql by confluentinc.

the class OldApiUtilsTest method shouldReturnEmbeddedResponseForKsqlRestException.

@Test
public void shouldReturnEmbeddedResponseForKsqlRestException() {
    final EndpointResponse response = EndpointResponse.failed(400);
    assertThat(OldApiUtils.mapException(new KsqlRestException(response)), sameInstance(response));
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) Test(org.junit.Test)

Example 22 with EndpointResponse

use of io.confluent.ksql.rest.EndpointResponse in project ksql by confluentinc.

the class ServerMetadataResourceTest method shouldReturnServerMetadata.

@Test
public void shouldReturnServerMetadata() {
    // When:
    final EndpointResponse response = serverMetadataResource.getServerMetadata();
    // Then:
    assertThat(response.getStatus(), equalTo(200));
    assertThat(response.getEntity(), instanceOf(ServerMetadata.class));
    final ServerMetadata serverMetadata = (ServerMetadata) response.getEntity();
    assertThat(serverMetadata, equalTo(new ServerMetadata(AppInfo.getVersion(), ServerClusterId.of(KAFKA_CLUSTER_ID, KSQL_SERVICE_ID))));
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) ServerMetadata(io.confluent.ksql.rest.entity.ServerMetadata) Test(org.junit.Test)

Example 23 with EndpointResponse

use of io.confluent.ksql.rest.EndpointResponse in project ksql by confluentinc.

the class ServerMetadataResourceTest method shouldReturnServerClusterId.

@Test
public void shouldReturnServerClusterId() {
    // When:
    final EndpointResponse response = serverMetadataResource.getServerClusterId();
    // Then:
    assertThat(response.getStatus(), equalTo(200));
    assertThat(response.getEntity(), instanceOf(ServerClusterId.class));
    final ServerClusterId serverClusterId = (ServerClusterId) response.getEntity();
    assertThat(serverClusterId, equalTo(ServerClusterId.of(KAFKA_CLUSTER_ID, KSQL_SERVICE_ID)));
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) ServerClusterId(io.confluent.ksql.rest.entity.ServerClusterId) Test(org.junit.Test)

Example 24 with EndpointResponse

use of io.confluent.ksql.rest.EndpointResponse in project ksql by confluentinc.

the class ClusterStatusResourceTest method shouldReturnClusterStatus.

@Test
public void shouldReturnClusterStatus() {
    // Given:
    when(heartbeatAgent.getHostsStatus()).thenReturn(HOSTS);
    when(lagReportingAgent.getLagPerHost(any())).thenReturn(Optional.empty());
    // When:
    final EndpointResponse response = clusterStatusResource.checkClusterStatus();
    // Then:
    assertThat(response.getStatus(), is(200));
    assertThat(response.getEntity(), instanceOf(ClusterStatusResponse.class));
    ClusterStatusResponse clusterStatusResponse = (ClusterStatusResponse) response.getEntity();
    assertTrue(clusterStatusResponse.getClusterStatus().get(HOST1_ENTITY).getHostAlive());
    assertFalse(clusterStatusResponse.getClusterStatus().get(HOST2_ENTITY).getHostAlive());
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) ClusterStatusResponse(io.confluent.ksql.rest.entity.ClusterStatusResponse) Test(org.junit.Test)

Example 25 with EndpointResponse

use of io.confluent.ksql.rest.EndpointResponse in project ksql by confluentinc.

the class ServerStateTest method shouldReturnErrorWhenInitializing.

@Test
public void shouldReturnErrorWhenInitializing() {
    // Given:
    final KsqlErrorMessage error = new KsqlErrorMessage(12345, "bad stuff is happening");
    serverState.setInitializingReason(error);
    // When:
    final Optional<EndpointResponse> result = serverState.checkReady();
    // Then:
    assertThat(result.isPresent(), is(true));
    final EndpointResponse response = result.get();
    final EndpointResponse expected = Errors.serverNotReady(error);
    assertThat(response.getStatus(), equalTo(expected.getStatus()));
    assertThat(response.getEntity(), equalTo(expected.getEntity()));
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) KsqlErrorMessage(io.confluent.ksql.rest.entity.KsqlErrorMessage) Test(org.junit.Test)

Aggregations

EndpointResponse (io.confluent.ksql.rest.EndpointResponse)30 Test (org.junit.Test)25 KsqlErrorMessage (io.confluent.ksql.rest.entity.KsqlErrorMessage)10 KsqlRequest (io.confluent.ksql.rest.entity.KsqlRequest)8 KsqlException (io.confluent.ksql.util.KsqlException)7 KsqlTopicAuthorizationException (io.confluent.ksql.exception.KsqlTopicAuthorizationException)6 HashMap (java.util.HashMap)6 MetricsCallbackHolder (io.confluent.ksql.api.server.MetricsCallbackHolder)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Query (io.confluent.ksql.parser.tree.Query)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 SessionConfig (io.confluent.ksql.config.SessionConfig)3 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)3 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)3 KsqlConfig (io.confluent.ksql.util.KsqlConfig)3 ImmutableList (com.google.common.collect.ImmutableList)2 AvroSchema (io.confluent.kafka.schemaregistry.avro.AvroSchema)2 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)2