Search in sources :

Example 26 with FakeAsyncResponse

use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.

the class TopicsResourceTest method deleteTopic_existingTopic_deletesTopic.

@Test
public void deleteTopic_existingTopic_deletesTopic() {
    expect(topicManager.deleteTopic(CLUSTER_ID, TOPIC_1.getName())).andReturn(completedFuture(null));
    replay(topicManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    topicsResource.deleteTopic(response, TOPIC_1.getClusterId(), TOPIC_1.getName());
    assertNull(response.getValue());
    assertNull(response.getException());
    assertTrue(response.isDone());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) Test(org.junit.jupiter.api.Test)

Example 27 with FakeAsyncResponse

use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.

the class TopicsResourceTest method deleteTopic_nonExistingCluster_throwsNotFound.

@Test
public void deleteTopic_nonExistingCluster_throwsNotFound() {
    expect(topicManager.deleteTopic(CLUSTER_ID, TOPIC_1.getName())).andReturn(failedFuture(new NotFoundException()));
    replay(topicManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    topicsResource.deleteTopic(response, TOPIC_1.getClusterId(), TOPIC_1.getName());
    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 28 with FakeAsyncResponse

use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.

the class TopicsResourceTest method getTopics_nonExistingCluster_throwsNotFoundException.

@Test
public void getTopics_nonExistingCluster_throwsNotFoundException() {
    expect(topicManager.getTopic(CLUSTER_ID, TOPIC_1.getName(), false)).andReturn(failedFuture(new NotFoundException()));
    replay(topicManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    topicsResource.getTopic(response, CLUSTER_ID, TOPIC_1.getName(), false);
    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 29 with FakeAsyncResponse

use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.

the class ClustersResourceTest method listClusters_timeoutException_returnsTimeoutException.

@Test
public void listClusters_timeoutException_returnsTimeoutException() {
    expect(clusterManager.listClusters()).andReturn(failedFuture(new TimeoutException()));
    replay(clusterManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    clustersResource.listClusters(response);
    assertEquals(TimeoutException.class, response.getException().getClass());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) TimeoutException(org.apache.kafka.common.errors.TimeoutException) Test(org.junit.jupiter.api.Test)

Example 30 with FakeAsyncResponse

use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.

the class ConsumerLagsResourceTest method listConsumerLags_returnsConsumerLags.

@Test
public void listConsumerLags_returnsConsumerLags() {
    expect(consumerLagManager.listConsumerLags(CLUSTER_ID, CONSUMER_GROUP_ID)).andReturn(completedFuture(CONSUMER_LAG_LIST));
    replay(consumerLagManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    consumerLagsResource.listConsumerLags(response, CLUSTER_ID, CONSUMER_GROUP_ID);
    ListConsumerLagsResponse expected = ListConsumerLagsResponse.create(ConsumerLagDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/lags").build()).setData(Arrays.asList(ConsumerLagData.fromConsumerLag(CONSUMER_LAG_2).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/" + "lags/topic-1/partitions/2").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1/" + "lag=topic-1/partition=2").build()).build(), ConsumerLagData.fromConsumerLag(CONSUMER_LAG_1).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/" + "lags/topic-1/partitions/1").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1/" + "lag=topic-1/partition=1").build()).build())).build());
    assertEquals(expected, response.getValue());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) ListConsumerLagsResponse(io.confluent.kafkarest.entities.v3.ListConsumerLagsResponse) 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