use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListSourceExecutorTest method shouldShowTablesExtended.
@Test
public void shouldShowTablesExtended() {
// Given:
final KsqlTable<?> table1 = engine.givenSource(DataSourceType.KTABLE, "table1");
final KsqlTable<?> table2 = engine.givenSource(DataSourceType.KTABLE, "table2", ImmutableSet.of(SourceName.of("table1")));
engine.givenSource(DataSourceType.KSTREAM, "stream");
// When:
final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.listTables().execute((ConfiguredStatement<ListTables>) engine.configure("LIST TABLES EXTENDED;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
final KafkaTopicClient client = engine.getServiceContext().getTopicClient();
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(table1, true, ImmutableList.of(), ImmutableList.of(), Optional.of(client.describeTopic(table1.getKafkaTopicName())), ImmutableList.of(), ImmutableList.of("table2"), new MetricCollectors()), SourceDescriptionFactory.create(table2, true, ImmutableList.of(), ImmutableList.of(), Optional.of(client.describeTopic(table1.getKafkaTopicName())), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListTopicsExecutorTest method shouldListKafkaTopicsWithoutInternalTopics.
@Test
public void shouldListKafkaTopicsWithoutInternalTopics() {
// Given:
engine.givenKafkaTopic("topic1");
engine.givenKafkaTopic("topic2");
engine.givenKafkaTopic("_confluent_any_topic");
// When:
final KafkaTopicsList topicsList = (KafkaTopicsList) CUSTOM_EXECUTORS.listTopics().execute((ConfiguredStatement<ListTopics>) engine.configure("LIST TOPICS;"), mock(SessionProperties.class), engine.getEngine(), serviceContext).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(topicsList.getTopics(), containsInAnyOrder(new KafkaTopicInfo("topic1", ImmutableList.of(1)), new KafkaTopicInfo("topic2", ImmutableList.of(1))));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListTopicsExecutorTest method shouldListKafkaTopicsThatDifferByCase.
@Test
public void shouldListKafkaTopicsThatDifferByCase() {
// Given:
engine.givenKafkaTopic("topic1");
engine.givenKafkaTopic("toPIc1");
// When:
final KafkaTopicsList topicsList = (KafkaTopicsList) CUSTOM_EXECUTORS.listTopics().execute((ConfiguredStatement<ListTopics>) engine.configure("LIST TOPICS;"), mock(SessionProperties.class), engine.getEngine(), serviceContext).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(topicsList.getTopics(), containsInAnyOrder(new KafkaTopicInfo("topic1", ImmutableList.of(1)), new KafkaTopicInfo("toPIc1", ImmutableList.of(1))));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListTopicsExecutorTest method shouldListKafkaTopicsExtended.
@Test
public void shouldListKafkaTopicsExtended() {
// Given:
engine.givenKafkaTopic("topic1");
engine.givenKafkaTopic("topic2");
final ListConsumerGroupsResult result = mock(ListConsumerGroupsResult.class);
final KafkaFutureImpl<Collection<ConsumerGroupListing>> groups = new KafkaFutureImpl<>();
when(result.all()).thenReturn(groups);
when(adminClient.listConsumerGroups()).thenReturn(result);
groups.complete(ImmutableList.of());
// When:
final KafkaTopicsListExtended topicsList = (KafkaTopicsListExtended) CUSTOM_EXECUTORS.listTopics().execute((ConfiguredStatement<ListTopics>) engine.configure("LIST TOPICS EXTENDED;"), mock(SessionProperties.class), engine.getEngine(), serviceContext).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(topicsList.getTopics(), containsInAnyOrder(new KafkaTopicInfoExtended("topic1", ImmutableList.of(1), 0, 0), new KafkaTopicInfoExtended("topic2", ImmutableList.of(1), 0, 0)));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ExplainExecutorTest method shouldFailOnNonQueryExplain.
@Test
public void shouldFailOnNonQueryExplain() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> customExecutors.explain().execute((ConfiguredStatement<Explain>) engine.configure("Explain SHOW TOPICS;"), sessionProperties, engine.getEngine(), engine.getServiceContext()));
// Then:
assertThat(e.getMessage(), containsString("The provided statement does not run a ksql query"));
}
Aggregations