use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ReplicasResourceTest method listReplicas_nonExistingPartitionOrTopicOrCluster_throwsNotFound.
@Test
public void listReplicas_nonExistingPartitionOrTopicOrCluster_throwsNotFound() {
expect(replicaManager.listReplicas(CLUSTER_ID, TOPIC_NAME, PARTITION_ID)).andReturn(failedFuture(new NotFoundException()));
replay(replicaManager);
FakeAsyncResponse response = new FakeAsyncResponse();
replicasResource.listReplicas(response, CLUSTER_ID, TOPIC_NAME, PARTITION_ID);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ReplicasResourceTest method listReplicas_existingPartition_returnsReplicas.
@Test
public void listReplicas_existingPartition_returnsReplicas() {
expect(replicaManager.listReplicas(CLUSTER_ID, TOPIC_NAME, PARTITION_ID)).andReturn(completedFuture(Arrays.asList(REPLICA_1, REPLICA_2, REPLICA_3)));
replay(replicaManager);
FakeAsyncResponse response = new FakeAsyncResponse();
replicasResource.listReplicas(response, CLUSTER_ID, TOPIC_NAME, PARTITION_ID);
ListReplicasResponse expected = ListReplicasResponse.create(ReplicaDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/0/replicas").build()).setData(Arrays.asList(ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/0" + "/replicas/1").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=0" + "/replica=1").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(PARTITION_ID).setBrokerId(REPLICA_1.getBrokerId()).setLeader(true).setInSync(true).setBroker(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1")).build(), ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/0" + "/replicas/2").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=0" + "/replica=2").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(PARTITION_ID).setBrokerId(REPLICA_2.getBrokerId()).setLeader(false).setInSync(true).setBroker(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/2")).build(), ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/0" + "/replicas/3").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=0" + "/replica=3").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(PARTITION_ID).setBrokerId(REPLICA_3.getBrokerId()).setLeader(false).setInSync(false).setBroker(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/3")).build())).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AlterBrokerConfigBatchActionTest method alterBrokerConfigs_existingConfig_alterConfigs.
@Test
public void alterBrokerConfigs_existingConfig_alterConfigs() {
expect(brokerConfigManager.alterBrokerConfigs(CLUSTER_ID, BROKER_ID, Arrays.asList(AlterConfigCommand.set(CONFIG_1.getName(), "newValue"), AlterConfigCommand.delete(CONFIG_2.getName())))).andReturn(completedFuture(null));
replay(brokerConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
alterBrokerConfigBatchAction.alterBrokerConfigBatch(response, CLUSTER_ID, BROKER_ID, AlterBrokerConfigBatchRequest.create(AlterConfigBatchRequestData.create(Arrays.asList(AlterEntry.builder().setName(CONFIG_1.getName()).setValue("newValue").build(), AlterEntry.builder().setName(CONFIG_2.getName()).setOperation(AlterOperation.DELETE).build()))));
assertNull(response.getValue());
assertNull(response.getException());
assertTrue(response.isDone());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AlterBrokerConfigBatchActionTest method alterBrokerConfigs_nonExistingCluster_throwsNotFound.
@Test
public void alterBrokerConfigs_nonExistingCluster_throwsNotFound() {
expect(brokerConfigManager.alterBrokerConfigs(CLUSTER_ID, BROKER_ID, Arrays.asList(AlterConfigCommand.set(CONFIG_1.getName(), "newValue"), AlterConfigCommand.delete(CONFIG_2.getName())))).andReturn(failedFuture(new NotFoundException()));
replay(brokerConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
alterBrokerConfigBatchAction.alterBrokerConfigBatch(response, CLUSTER_ID, BROKER_ID, AlterBrokerConfigBatchRequest.create(AlterConfigBatchRequestData.create(Arrays.asList(AlterEntry.builder().setName(CONFIG_1.getName()).setValue("newValue").build(), AlterEntry.builder().setName(CONFIG_2.getName()).setOperation(AlterOperation.DELETE).build()))));
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClusterConfigResourceTest method updateConfig_nonExistingCluster_throwsNotFound.
@Test
public void updateConfig_nonExistingCluster_throwsNotFound() {
expect(clusterConfigManager.upsertClusterConfig(CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName(), "new-value")).andReturn(failedFuture(new NotFoundException()));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clusterConfigsResource.upsertClusterConfig(response, CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName(), UpdateClusterConfigRequest.create("new-value"));
assertEquals(NotFoundException.class, response.getException().getClass());
}
Aggregations