Search in sources :

Example 6 with Topic

use of io.confluent.kafkarest.entities.Topic in project kafka-rest by confluentinc.

the class TopicManagerImplTest method listTopics_existingCluster_returnsTopicsWithAuthOperations.

@Test
public void listTopics_existingCluster_returnsTopicsWithAuthOperations() throws Exception {
    expect(clusterManager.getCluster(CLUSTER_ID)).andReturn(completedFuture(Optional.of(CLUSTER)));
    expect(adminClient.listTopics()).andReturn(listTopicsResult);
    expect(listTopicsResult.listings()).andReturn(KafkaFuture.completedFuture(singletonList(new TopicListing("topic-4", false))));
    expect(adminClient.describeTopics(isA(Collection.class), anyObject())).andReturn(describeTopicResult);
    expect(describeTopicResult.all()).andReturn(KafkaFuture.completedFuture(createTopicDescriptionMap(TOPIC_DESCRIPTION_4)));
    replay(clusterManager, adminClient, listTopicsResult, describeTopicResult);
    List<Topic> topics = topicManager.listTopics(CLUSTER_ID, true).get();
    assertEquals(Arrays.asList(TOPIC_4), topics);
}
Also used : TopicListing(org.apache.kafka.clients.admin.TopicListing) Collection(java.util.Collection) Topic(io.confluent.kafkarest.entities.Topic) NewTopic(org.apache.kafka.clients.admin.NewTopic) Test(org.junit.jupiter.api.Test)

Aggregations

Topic (io.confluent.kafkarest.entities.Topic)6 NewTopic (org.apache.kafka.clients.admin.NewTopic)4 Collection (java.util.Collection)3 List (java.util.List)3 Test (org.junit.jupiter.api.Test)3 TopicManager (io.confluent.kafkarest.controllers.TopicManager)2 ResourceName (io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName)2 PerformanceMetric (io.confluent.rest.annotations.PerformanceMetric)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 GET (javax.ws.rs.GET)2 TopicListing (org.apache.kafka.clients.admin.TopicListing)2 Errors (io.confluent.kafkarest.Errors)1 Versions (io.confluent.kafkarest.Versions)1 KafkaFutures (io.confluent.kafkarest.common.KafkaFutures)1 Entities.checkEntityExists (io.confluent.kafkarest.controllers.Entities.checkEntityExists)1 TopicConfigManager (io.confluent.kafkarest.controllers.TopicConfigManager)1 Acl (io.confluent.kafkarest.entities.Acl)1