use of io.confluent.ksql.rest.entity.ErrorMessageEntity in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailForIncorrectDropTableStatement.
@Test
public void shouldFailForIncorrectDropTableStatement() throws Exception {
KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
final String ksqlString = "DROP STREAM test_table;";
Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, Collections.emptyMap()));
KsqlEntityList result = (KsqlEntityList) response.getEntity();
assertThat("Incorrect drop statement.", result.size(), equalTo(1));
assertThat(result.get(0), instanceOf(ErrorMessageEntity.class));
ErrorMessageEntity errorMessageEntity = (ErrorMessageEntity) result.get(0);
assertTrue(errorMessageEntity.getErrorMessage().getMessage().equalsIgnoreCase("Incompatible data source type" + " is TABLE, but statement was DROP STREAM"));
}
use of io.confluent.ksql.rest.entity.ErrorMessageEntity in project ksql by confluentinc.
the class ConsoleTest method testPrintKSqlEntityList.
@Test
public void testPrintKSqlEntityList() throws IOException {
Map<String, Object> properties = new HashMap<>();
properties.put("k1", 1);
properties.put("k2", "v2");
properties.put("k3", true);
List<Queries.RunningQuery> queries = new ArrayList<>();
queries.add(new Queries.RunningQuery("select * from t1", "TestTopic", new QueryId("0")));
for (int i = 0; i < 5; i++) {
KsqlEntityList entityList = new KsqlEntityList(Arrays.asList(new CommandStatusEntity("e", "topic/1/create", "SUCCESS", "Success Message"), new ErrorMessageEntity("e", new FakeException()), new PropertiesList("e", properties), new Queries("e", queries), new SourceDescription("e", "TestSource", Collections.EMPTY_LIST, Collections.EMPTY_LIST, buildTestSchema(i), DataSource.DataSourceType.KTABLE.getKqlType(), "key", "2000-01-01", "stats", "errors", false, "avro", "kadka-topic", "topology", "executionPlan", 1, 1), new TopicDescription("e", "TestTopic", "TestKafkaTopic", "AVRO", "schemaString"), new StreamsList("e", Arrays.asList(new SourceInfo.Stream("TestStream", "TestTopic", "AVRO"))), new TablesList("e", Arrays.asList(new SourceInfo.Table("TestTable", "TestTopic", "JSON", false))), new KsqlTopicsList("e", Arrays.asList(new KsqlTopicInfo("TestTopic", "TestKafkaTopic", DataSource.DataSourceSerDe.JSON))), new KafkaTopicsList("e", Arrays.asList(new KafkaTopicInfo("TestKafkaTopic", true, ImmutableList.of(1), 1, 1))), new ExecutionPlan("Test Execution Plan")));
terminal.printKsqlEntityList(entityList);
}
}
use of io.confluent.ksql.rest.entity.ErrorMessageEntity in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailForIncorrectCTASStatementResultType.
@Test
public void shouldFailForIncorrectCTASStatementResultType() throws Exception {
KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
final String ksqlString = "CREATE TABLE s1 AS SELECT * FROM test_stream;";
Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, Collections.emptyMap()));
KsqlEntityList result = (KsqlEntityList) response.getEntity();
assertThat("Incorrect response size.", result.size(), equalTo(1));
assertThat(result.get(0), instanceOf(ErrorMessageEntity.class));
ErrorMessageEntity errorMessageEntity = (ErrorMessageEntity) result.get(0);
assertTrue(errorMessageEntity.getErrorMessage().getMessage().contains("Invalid result type. Your " + "SELECT query produces a STREAM. Please use CREATE STREAM AS SELECT statement instead."));
}
Aggregations