use of io.confluent.ksql.rest.entity.SourceDescriptionList in project ksql by confluentinc.
the class ListSourceExecutorTest method shouldDescribeStreams.
@Test
public void shouldDescribeStreams() {
// Given:
final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "stream1");
final KsqlStream<?> stream2 = engine.givenSource(DataSourceType.KSTREAM, "stream2", ImmutableSet.of(SourceName.of("stream1")));
engine.givenSource(DataSourceType.KTABLE, "table");
// When:
final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.describeStreams().execute((ConfiguredStatement<DescribeStreams>) engine.configure("DESCRIBE STREAMS;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(stream1, false, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of("stream2"), new MetricCollectors()), SourceDescriptionFactory.create(stream2, false, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
use of io.confluent.ksql.rest.entity.SourceDescriptionList in project ksql by confluentinc.
the class ListSourceExecutorTest method shouldShowStreamsExtended.
@Test
public void shouldShowStreamsExtended() {
// Given:
final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "stream1");
final KsqlStream<?> stream2 = engine.givenSource(DataSourceType.KSTREAM, "stream2", ImmutableSet.of(SourceName.of("stream1")));
engine.givenSource(DataSourceType.KTABLE, "table");
// When:
final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.listStreams().execute((ConfiguredStatement<ListStreams>) engine.configure("SHOW STREAMS EXTENDED;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(stream1, true, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of("stream2"), new MetricCollectors()), SourceDescriptionFactory.create(stream2, true, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
use of io.confluent.ksql.rest.entity.SourceDescriptionList in project ksql by confluentinc.
the class ListSourceExecutor method sourceDescriptionList.
private static Optional<KsqlEntity> sourceDescriptionList(final ConfiguredStatement<? extends StatementWithExtendedClause> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext, final List<? extends DataSource> sources, final boolean extended) {
final RemoteHostExecutor remoteHostExecutor = RemoteHostExecutor.create(statement, sessionProperties, executionContext, serviceContext.getKsqlClient());
final Multimap<String, SourceDescription> remoteSourceDescriptions = extended ? RemoteSourceDescriptionExecutor.fetchSourceDescriptions(remoteHostExecutor) : ImmutableMultimap.of();
final List<SourceDescriptionWithWarnings> descriptions = sources.stream().map(s -> describeSource(statement.getSessionConfig().getConfig(false), executionContext, serviceContext, s.getName(), extended, statement, sessionProperties, remoteSourceDescriptions.get(s.getName().toString()))).collect(Collectors.toList());
return Optional.of(new SourceDescriptionList(statement.getStatementText(), descriptions.stream().map(d -> d.description).collect(Collectors.toList()), descriptions.stream().flatMap(d -> d.warnings.stream()).collect(Collectors.toList())));
}
Aggregations