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