Search in sources :

Example 6 with EndpointResponse

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

the class HealthCheckResourceTest method shouldGetCachedResponse.

@Test
public void shouldGetCachedResponse() {
    // Given:
    healthCheckResource.checkHealth();
    // When:
    final EndpointResponse response = healthCheckResource.checkHealth();
    // Then:
    assertThat(response.getEntity(), sameInstance(response1));
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) Test(org.junit.Test)

Example 7 with EndpointResponse

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

the class ClusterStatusResourceTest method shouldReturnEmptyLagsForDeadHost.

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

Example 8 with EndpointResponse

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

the class HeartbeatResourceTest method shouldSendHeartbeat.

@Test
public void shouldSendHeartbeat() {
    // When:
    final HeartbeatMessage request = new HeartbeatMessage(new KsqlHostInfoEntity("localhost", 8080), 1);
    final EndpointResponse response = heartbeatResource.registerHeartbeat(request);
    // Then:
    assertThat(response.getStatus(), is(200));
    assertThat(response.getEntity(), instanceOf(HeartbeatResponse.class));
}
Also used : HeartbeatResponse(io.confluent.ksql.rest.entity.HeartbeatResponse) EndpointResponse(io.confluent.ksql.rest.EndpointResponse) HeartbeatMessage(io.confluent.ksql.rest.entity.HeartbeatMessage) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) Test(org.junit.Test)

Example 9 with EndpointResponse

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

the class StatusResourceTest method testGetStatusNotFound.

@Test
public void testGetStatusNotFound() throws Exception {
    final StatusResource testResource = getTestStatusResource();
    final EndpointResponse response = testResource.getStatus(CommandId.Type.STREAM.name(), "foo", CommandId.Action.CREATE.name());
    assertThat(response.getStatus(), equalTo(NOT_FOUND.code()));
    assertThat(response.getEntity(), instanceOf(KsqlErrorMessage.class));
    final KsqlErrorMessage errorMessage = (KsqlErrorMessage) response.getEntity();
    assertThat(errorMessage.getErrorCode(), equalTo(Errors.ERROR_CODE_NOT_FOUND));
    assertThat(errorMessage.getMessage(), equalTo("Command not found"));
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) KsqlErrorMessage(io.confluent.ksql.rest.entity.KsqlErrorMessage) Test(org.junit.Test)

Example 10 with EndpointResponse

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

the class ServerStateTest method shouldReturnErrorWhenTerminating.

@Test
public void shouldReturnErrorWhenTerminating() {
    // Given:
    serverState.setTerminating();
    // When:
    final Optional<EndpointResponse> result = serverState.checkReady();
    // Then:
    assertThat(result.isPresent(), is(true));
    final EndpointResponse response = result.get();
    final EndpointResponse expected = Errors.serverShuttingDown();
    assertThat(response.getStatus(), equalTo(expected.getStatus()));
    assertThat(response.getEntity(), equalTo(expected.getEntity()));
}
Also used : EndpointResponse(io.confluent.ksql.rest.EndpointResponse) 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