Search in sources :

Example 41 with FakeAsyncResponse

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());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 42 with FakeAsyncResponse

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());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) Test(org.junit.jupiter.api.Test)

Example 43 with FakeAsyncResponse

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());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) GetBrokerResponse(io.confluent.kafkarest.entities.v3.GetBrokerResponse) Test(org.junit.jupiter.api.Test)

Example 44 with FakeAsyncResponse

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());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 45 with FakeAsyncResponse

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());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Aggregations

FakeAsyncResponse (io.confluent.kafkarest.response.FakeAsyncResponse)107 Test (org.junit.jupiter.api.Test)107 NotFoundException (javax.ws.rs.NotFoundException)35 ProduceRequest (io.confluent.kafkarest.entities.v3.ProduceRequest)6 RequestRateLimiter (io.confluent.kafkarest.ratelimit.RequestRateLimiter)6 ChunkedOutputFactory (io.confluent.kafkarest.response.ChunkedOutputFactory)6 Properties (java.util.Properties)6 ResultOrError (io.confluent.kafkarest.response.StreamingResponse.ResultOrError)5 CreateTopicResponse (io.confluent.kafkarest.entities.v3.CreateTopicResponse)4 ProduceResponse (io.confluent.kafkarest.entities.v3.ProduceResponse)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 ConfigSynonymData (io.confluent.kafkarest.entities.v3.ConfigSynonymData)3 ListBrokerConfigsResponse (io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse)3 ListTopicConfigsResponse (io.confluent.kafkarest.entities.v3.ListTopicConfigsResponse)3 ErrorResponse (io.confluent.kafkarest.exceptions.v3.ErrorResponse)3 BrokerConfig (io.confluent.kafkarest.entities.BrokerConfig)2 TopicConfig (io.confluent.kafkarest.entities.TopicConfig)2 RateLimitExceededException (io.confluent.kafkarest.ratelimit.RateLimitExceededException)2 TimeoutException (org.apache.kafka.common.errors.TimeoutException)2