private KsqlEntity listTables(final PreparedStatement<ListTables> statement) { final List<KsqlTable> ksqlTables = getSpecificSources(KsqlTable.class); if (statement.getStatement().getShowExtended()) { return new SourceDescriptionList( statement.getStatementText(), ksqlTables.stream() .map(t -> describeSource(t.getName(), true)) .collect(Collectors.toList())); } return new TablesList( statement.getStatementText(), ksqlTables.stream() .map(SourceInfo.Table::new) .collect(Collectors.toList())); }
new TopicDescription("e", "TestTopic", "TestKafkaTopic", "AVRO", "schemaString"), new StreamsList("e", ImmutableList.of(new SourceInfo.Stream("TestStream", "TestTopic", "AVRO"))), new TablesList("e", ImmutableList.of(new SourceInfo.Table("TestTable", "TestTopic", "JSON", false))), new KsqlTopicsList("e", ImmutableList.of(new KsqlTopicInfo("TestTopic", "TestKafkaTopic", DataSource.DataSourceSerDe.JSON))), new KafkaTopicsList("e", ImmutableList.of(new KafkaTopicInfo("TestKafkaTopic", true, ImmutableList.of(1), 1, 1))),
@Override public int hashCode() { return Objects.hash(getTables()); } }
@Override public Table buildTable(final TablesList entity) { final Stream<List<String>> rows = entity.getTables().stream() .map(t -> ImmutableList.of(t.getName(), t.getTopic(), t.getFormat(), Boolean.toString(t.getIsWindowed()))); return new Builder() .withColumnHeaders(HEADERS) .withRows(rows) .build(); } }
@Test public void shouldListTablesStatement() { // When: final TablesList tablesList = makeSingleRequest("LIST TABLES;", TablesList.class); // Then: assertThat(tablesList.getTables(), contains(sourceTable("TEST_TABLE"))); }