Search in sources :

Example 1 with ListConsumerGroupsResult

use of org.apache.kafka.clients.admin.ListConsumerGroupsResult 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)));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KafkaTopicInfoExtended(io.confluent.ksql.rest.entity.KafkaTopicInfoExtended) Collection(java.util.Collection) KafkaTopicsListExtended(io.confluent.ksql.rest.entity.KafkaTopicsListExtended) KafkaFutureImpl(org.apache.kafka.common.internals.KafkaFutureImpl) ListConsumerGroupsResult(org.apache.kafka.clients.admin.ListConsumerGroupsResult) Test(org.junit.Test)

Aggregations

KafkaTopicInfoExtended (io.confluent.ksql.rest.entity.KafkaTopicInfoExtended)1 KafkaTopicsListExtended (io.confluent.ksql.rest.entity.KafkaTopicsListExtended)1 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)1 Collection (java.util.Collection)1 ListConsumerGroupsResult (org.apache.kafka.clients.admin.ListConsumerGroupsResult)1 KafkaFutureImpl (org.apache.kafka.common.internals.KafkaFutureImpl)1 Test (org.junit.Test)1