use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class OldApiUtilsTest method shouldReturnCorrectResponseForUnspecificException.
@Test
public void shouldReturnCorrectResponseForUnspecificException() {
final EndpointResponse response = OldApiUtils.mapException(new Exception("error msg"));
assertThat(response.getEntity(), instanceOf(KsqlErrorMessage.class));
final KsqlErrorMessage errorMessage = (KsqlErrorMessage) response.getEntity();
assertThat(errorMessage.getMessage(), equalTo("error msg"));
assertThat(errorMessage.getErrorCode(), equalTo(Errors.ERROR_CODE_SERVER_ERROR));
assertThat(response.getStatus(), equalTo(INTERNAL_SERVER_ERROR.code()));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailForIncorrectDropStreamStatement.
@Test
public void shouldFailForIncorrectDropStreamStatement() {
// When:
final KsqlErrorMessage result = makeFailingRequest("DROP TABLE test_stream;", BAD_REQUEST.code());
// Then:
assertThat(result.getMessage().toLowerCase(), is("incompatible data source type is stream, but statement was drop table"));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class KsqlResourceTest method shouldReportErrorOnNonQueryExplain.
@Test
public void shouldReportErrorOnNonQueryExplain() {
// Given:
final String ksqlQueryString = "SHOW TOPICS;";
final String ksqlString = "EXPLAIN " + ksqlQueryString;
// When:
final KsqlErrorMessage result = makeFailingRequest(ksqlString, BAD_REQUEST.code());
// Then:
assertThat(result.getErrorCode(), is(Errors.ERROR_CODE_BAD_STATEMENT));
assertThat(result.getMessage(), is("The provided statement does not run a ksql query"));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailForIncorrectDropTableStatement.
@Test
public void shouldFailForIncorrectDropTableStatement() {
// When:
final KsqlErrorMessage result = makeFailingRequest("DROP STREAM test_table;", BAD_REQUEST.code());
// Then:
assertThat(result.getMessage().toLowerCase(), is("incompatible data source type is table, but statement was drop stream"));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailWhenAvroInferenceFailsDuringValidate.
@Test
public void shouldFailWhenAvroInferenceFailsDuringValidate() {
// Given:
when(sandboxSchemaInjector.inject(any())).thenThrow(new KsqlStatementException("boom", "sql"));
// When:
final KsqlErrorMessage result = makeFailingRequest("CREATE STREAM S WITH(KEY_FORMAT='KAFKA', VALUE_FORMAT='AVRO', KAFKA_TOPIC='orders-topic');", BAD_REQUEST.code());
// Then:
assertThat(result.getErrorCode(), is(Errors.ERROR_CODE_BAD_STATEMENT));
assertThat(result.getMessage(), is("boom"));
}
Aggregations