use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClusterConfigResourceTest method getClusterConfig_nonExistingCluster_throwsNotFound.
@Test
public void getClusterConfig_nonExistingCluster_throwsNotFound() {
expect(clusterConfigManager.getClusterConfig(CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName())).andReturn(failedFuture(new NotFoundException()));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clusterConfigsResource.getClusterConfig(response, CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerAssignmentsResourceTest method getConsumer_nonExistingConsumer_throwsNotFound.
@Test
public void getConsumer_nonExistingConsumer_throwsNotFound() {
expect(consumerAssignmentManager.getConsumerAssignment(CLUSTER_ID, CONSUMER_GROUP_ID, CONSUMER_ID, "topic-1", 1)).andReturn(completedFuture(Optional.empty()));
replay(consumerAssignmentManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerAssignmentsResource.getConsumerAssignment(response, CLUSTER_ID, CONSUMER_GROUP_ID, CONSUMER_ID, "topic-1", 1);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerAssignmentsResourceTest method getConsumer_returnsConsumer.
@Test
public void getConsumer_returnsConsumer() {
expect(consumerAssignmentManager.getConsumerAssignment(CLUSTER_ID, CONSUMER_GROUP_ID, CONSUMER_ID, "topic-1", 1)).andReturn(completedFuture(Optional.of(CONSUMER_ASSIGNMENT_1)));
replay(consumerAssignmentManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerAssignmentsResource.getConsumerAssignment(response, CLUSTER_ID, CONSUMER_GROUP_ID, CONSUMER_ID, "topic-1", 1);
GetConsumerAssignmentResponse expected = GetConsumerAssignmentResponse.create(ConsumerAssignmentData.fromConsumerAssignment(CONSUMER_ASSIGNMENT_1).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-1" + "/assignments/topic-1/partitions/1").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1" + "/consumer=consumer-1" + "/assignment=topic-1/partition=1").build()).setPartition(Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/1")).setLag(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/lags" + "/topic-1/partitions/1")).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerGroupsResourceTest method getConsumerGroup_returnsConsumerGroup.
@Test
public void getConsumerGroup_returnsConsumerGroup() {
expect(consumerGroupManager.getConsumerGroup(CLUSTER_ID, CONSUMER_GROUPS[0].getConsumerGroupId())).andReturn(completedFuture(Optional.of(CONSUMER_GROUPS[0])));
replay(consumerGroupManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerGroupsResource.getConsumerGroup(response, CLUSTER_ID, CONSUMER_GROUPS[0].getConsumerGroupId());
GetConsumerGroupResponse expected = GetConsumerGroupResponse.create(ConsumerGroupData.fromConsumerGroup(CONSUMER_GROUPS[0]).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1").build()).setCoordinator(Relationship.create("/v3/clusters/cluster-1/brokers/1")).setConsumers(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/consumers")).setLagSummary(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/lag-summary")).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerGroupsResourceTest method listConsumerGroups_returnsConsumerGroups.
@Test
public void listConsumerGroups_returnsConsumerGroups() {
expect(consumerGroupManager.listConsumerGroups(CLUSTER_ID)).andReturn(completedFuture(Arrays.asList(CONSUMER_GROUPS)));
replay(consumerGroupManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerGroupsResource.listConsumerGroups(response, CLUSTER_ID);
ListConsumerGroupsResponse expected = ListConsumerGroupsResponse.create(ConsumerGroupDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups").build()).setData(Arrays.asList(ConsumerGroupData.fromConsumerGroup(CONSUMER_GROUPS[0]).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1").build()).setCoordinator(Relationship.create("/v3/clusters/cluster-1/brokers/1")).setConsumers(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers")).setLagSummary(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/lag-summary")).build(), ConsumerGroupData.fromConsumerGroup(CONSUMER_GROUPS[1]).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-2").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-2").build()).setCoordinator(Relationship.create("/v3/clusters/cluster-1/brokers/2")).setConsumers(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-2" + "/consumers")).setLagSummary(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-2" + "/lag-summary")).build())).build());
assertEquals(expected, response.getValue());
}
Aggregations