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));
}
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());
}
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));
}
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"));
}
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()));
}
Aggregations