Search in sources :

Example 96 with FakeAsyncResponse

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

the class GetReassignmentActionTest method getReassignment_nonExistingCluster_throwsNotFound.

@Test
public void getReassignment_nonExistingCluster_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)

Example 97 with FakeAsyncResponse

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

the class GetReassignmentActionTest method getReassignment_nonExistingTopic_throwsNotFound.

@Test
public void getReassignment_nonExistingTopic_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)

Example 98 with FakeAsyncResponse

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

the class ListAllReassignmentsActionTest method listAllReassignments_nonExistingCluster_throwsNotFound.

@Test
public void listAllReassignments_nonExistingCluster_throwsNotFound() {
    expect(reassignmentManager.listReassignments(CLUSTER_ID)).andReturn(failedFuture(new NotFoundException()));
    replay(reassignmentManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    listAllReassignmentsAction.listReassignments(response, CLUSTER_ID);
    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 99 with FakeAsyncResponse

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

the class PartitionsResourceTest method listPartitions_existingTopic_returnsPartitions.

@Test
public void listPartitions_existingTopic_returnsPartitions() {
    expect(partitionManager.listPartitions(CLUSTER_ID, TOPIC_NAME)).andReturn(CompletableFuture.completedFuture(Arrays.asList(PARTITION_1, PARTITION_2, PARTITION_3)));
    replay(partitionManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    partitionsResource.listPartitions(response, CLUSTER_ID, TOPIC_NAME);
    ListPartitionsResponse expected = ListPartitionsResponse.create(PartitionDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions").build()).setData(Arrays.asList(PartitionData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/0").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=0").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(PARTITION_1.getPartitionId()).setLeader(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/0" + "/replicas/1")).setReplicas(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/0/replicas")).setReassignment(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/0" + "/reassignment")).build(), PartitionData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/1").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=1").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(PARTITION_2.getPartitionId()).setLeader(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/1" + "/replicas/2")).setReplicas(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/1/replicas")).setReassignment(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/1" + "/reassignment")).build(), PartitionData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/2").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=2").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(PARTITION_3.getPartitionId()).setLeader(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/2" + "/replicas/3")).setReplicas(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/2/replicas")).setReassignment(Resource.Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/2/reassignment")).build())).build());
    assertEquals(expected, response.getValue());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) ListPartitionsResponse(io.confluent.kafkarest.entities.v3.ListPartitionsResponse) Test(org.junit.jupiter.api.Test)

Example 100 with FakeAsyncResponse

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

the class PartitionsResourceTest method getPartition_nonExistingTopicOrCluster_throwsNotFound.

@Test
public void getPartition_nonExistingTopicOrCluster_throwsNotFound() {
    expect(partitionManager.getPartition(CLUSTER_ID, TOPIC_NAME, PARTITION_1.getPartitionId())).andReturn(failedFuture(new NotFoundException()));
    replay(partitionManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    partitionsResource.getPartition(response, CLUSTER_ID, TOPIC_NAME, PARTITION_1.getPartitionId());
    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