use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AlterTopicConfigBatchActionTest method alterTopicConfigs_nonExistingCluster_throwsNotFound.
@Test
public void alterTopicConfigs_nonExistingCluster_throwsNotFound() {
expect(topicConfigManager.alterTopicConfigs(CLUSTER_ID, TOPIC_NAME, Arrays.asList(AlterConfigCommand.set(CONFIG_1.getName(), "newValue"), AlterConfigCommand.delete(CONFIG_2.getName())))).andReturn(failedFuture(new NotFoundException()));
replay(topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
alterTopicConfigBatchAction.alterTopicConfigBatch(response, CLUSTER_ID, TOPIC_NAME, AlterTopicConfigBatchRequest.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 BrokersResourceTest method getBroker_existingClusterNonExistingBroker_throwsNotFound.
@Test
public void getBroker_existingClusterNonExistingBroker_throwsNotFound() {
expect(brokerManager.getBroker(CLUSTER_ID, 4)).andReturn(CompletableFuture.completedFuture(Optional.empty()));
replay(brokerManager);
FakeAsyncResponse response = new FakeAsyncResponse();
brokersResource.getBroker(response, CLUSTER_ID, 4);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class BrokersResourceTest method getBroker_existingClusterExistingBroker_returnsBroker.
@Test
public void getBroker_existingClusterExistingBroker_returnsBroker() {
expect(brokerManager.getBroker(CLUSTER_ID, BROKER_1.getBrokerId())).andReturn(CompletableFuture.completedFuture(Optional.of(BROKER_1)));
replay(brokerManager);
FakeAsyncResponse response = new FakeAsyncResponse();
brokersResource.getBroker(response, CLUSTER_ID, BROKER_1.getBrokerId());
GetBrokerResponse expected = GetBrokerResponse.create(BrokerData.builder().setMetadata(Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1").setResourceName("crn:///kafka=cluster-1/broker=1").build()).setClusterId(CLUSTER_ID).setBrokerId(BROKER_1.getBrokerId()).setHost(BROKER_1.getHost()).setPort(BROKER_1.getPort()).setRack(BROKER_1.getRack()).setConfigs(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1/configs")).setPartitionReplicas(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1/partition-replicas")).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicConfigsResourceTest method updateTopicConfig_nonExistingConfigOrTopicOrCluster_throwsNotFound.
@Test
public void updateTopicConfig_nonExistingConfigOrTopicOrCluster_throwsNotFound() {
expect(topicConfigManager.updateTopicConfig(CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName(), "new-value")).andReturn(failedFuture(new NotFoundException()));
replay(topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicConfigsResource.updateTopicConfig(response, CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName(), UpdateTopicConfigRequest.create("new-value"));
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class GetReassignmentActionTest method getReassignment_nonExistingPartition_throwsNotFound.
@Test
public void getReassignment_nonExistingPartition_throwsNotFound() {
expect(reassignmentManager.getReassignment(CLUSTER_ID, TOPIC_1, 1)).andReturn(failedFuture(new NotFoundException()));
replay(reassignmentManager);
FakeAsyncResponse response = new FakeAsyncResponse();
getReassignmentAction.getReassignment(response, CLUSTER_ID, "topic-1", 1);
assertEquals(NotFoundException.class, response.getException().getClass());
}
Aggregations