use of io.confluent.kafkarest.entities.v3.ListTopicsResponse in project kafka-rest by confluentinc.
the class TopicsResourceIntegrationTest method listTopics_existingCluster_returnsTopics.
@Test
public void listTopics_existingCluster_returnsTopics() {
String baseUrl = restConnect;
String clusterId = getClusterId();
ListTopicsResponse expected = ListTopicsResponse.create(TopicDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/topics").build()).setData(Arrays.asList(TopicData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_1).setResourceName("crn:///kafka=" + clusterId + "/topic=" + TOPIC_1).build()).setClusterId(clusterId).setTopicName(TOPIC_1).setInternal(false).setReplicationFactor(1).setPartitionsCount(1).setPartitions(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_1 + "/partitions")).setConfigs(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_1 + "/configs")).setPartitionReassignments(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_1 + "/partitions/-/reassignment")).setAuthorizedOperations(emptySet()).build(), TopicData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_2).setResourceName("crn:///kafka=" + clusterId + "/topic=" + TOPIC_2).build()).setClusterId(clusterId).setTopicName(TOPIC_2).setInternal(false).setReplicationFactor(1).setPartitionsCount(1).setPartitions(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_2 + "/partitions")).setConfigs(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_2 + "/configs")).setPartitionReassignments(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_2 + "/partitions/-/reassignment")).setAuthorizedOperations(emptySet()).build(), TopicData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_3).setResourceName("crn:///kafka=" + clusterId + "/topic=" + TOPIC_3).build()).setClusterId(clusterId).setTopicName(TOPIC_3).setInternal(false).setReplicationFactor(1).setPartitionsCount(1).setPartitions(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_3 + "/partitions")).setConfigs(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_3 + "/configs")).setPartitionReassignments(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_3 + "/partitions/-/reassignment")).setAuthorizedOperations(emptySet()).build())).build());
testWithRetry(() -> {
Response response = request("/v3/clusters/" + clusterId + "/topics").accept(MediaType.APPLICATION_JSON).get();
assertEquals(Status.OK.getStatusCode(), response.getStatus());
ListTopicsResponse actual = response.readEntity(ListTopicsResponse.class);
assertEquals(expected, actual);
});
}
use of io.confluent.kafkarest.entities.v3.ListTopicsResponse in project java-pubsub by googleapis.
the class TopicAdminClientTest method listTopicsTest2.
@Test
public void listTopicsTest2() throws Exception {
Topic responsesElement = Topic.newBuilder().build();
ListTopicsResponse expectedResponse = ListTopicsResponse.newBuilder().setNextPageToken("").addAllTopics(Arrays.asList(responsesElement)).build();
mockPublisher.addResponse(expectedResponse);
String project = "project-309310695";
ListTopicsPagedResponse pagedListResponse = client.listTopics(project);
List<Topic> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTopicsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockPublisher.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTopicsRequest actualRequest = ((ListTopicsRequest) actualRequests.get(0));
Assert.assertEquals(project, actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations