Search in sources :

Example 1 with OffsetDeleteResponseData

use of org.apache.kafka.common.message.OffsetDeleteResponseData in project kafka by apache.

the class KafkaAdminClientTest method testDeleteConsumerGroupOffsets.

@Test
public void testDeleteConsumerGroupOffsets() throws Exception {
    // Happy path
    final TopicPartition tp1 = new TopicPartition("foo", 0);
    final TopicPartition tp2 = new TopicPartition("bar", 0);
    final TopicPartition tp3 = new TopicPartition("foobar", 0);
    try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(mockCluster(1, 0))) {
        env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
        env.kafkaClient().prepareResponse(prepareFindCoordinatorResponse(Errors.NONE, env.cluster().controller()));
        env.kafkaClient().prepareResponse(new OffsetDeleteResponse(new OffsetDeleteResponseData().setTopics(new OffsetDeleteResponseTopicCollection(Stream.of(new OffsetDeleteResponseTopic().setName("foo").setPartitions(new OffsetDeleteResponsePartitionCollection(Collections.singletonList(new OffsetDeleteResponsePartition().setPartitionIndex(0).setErrorCode(Errors.NONE.code())).iterator())), new OffsetDeleteResponseTopic().setName("bar").setPartitions(new OffsetDeleteResponsePartitionCollection(Collections.singletonList(new OffsetDeleteResponsePartition().setPartitionIndex(0).setErrorCode(Errors.GROUP_SUBSCRIBED_TO_TOPIC.code())).iterator()))).collect(Collectors.toList()).iterator()))));
        final DeleteConsumerGroupOffsetsResult errorResult = env.adminClient().deleteConsumerGroupOffsets(GROUP_ID, Stream.of(tp1, tp2).collect(Collectors.toSet()));
        assertNull(errorResult.partitionResult(tp1).get());
        TestUtils.assertFutureError(errorResult.all(), GroupSubscribedToTopicException.class);
        TestUtils.assertFutureError(errorResult.partitionResult(tp2), GroupSubscribedToTopicException.class);
        assertThrows(IllegalArgumentException.class, () -> errorResult.partitionResult(tp3));
    }
}
Also used : OffsetDeleteResponsePartitionCollection(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponsePartitionCollection) OffsetDeleteResponseTopic(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponseTopic) OffsetDeleteResponsePartition(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponsePartition) OffsetDeleteResponse(org.apache.kafka.common.requests.OffsetDeleteResponse) TopicPartition(org.apache.kafka.common.TopicPartition) OffsetDeleteResponseTopicCollection(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponseTopicCollection) OffsetDeleteResponseData(org.apache.kafka.common.message.OffsetDeleteResponseData) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with OffsetDeleteResponseData

use of org.apache.kafka.common.message.OffsetDeleteResponseData in project kafka by apache.

the class RequestResponseTest method createOffsetDeleteResponse.

private OffsetDeleteResponse createOffsetDeleteResponse() {
    OffsetDeleteResponsePartitionCollection partitions = new OffsetDeleteResponsePartitionCollection();
    partitions.add(new OffsetDeleteResponsePartition().setPartitionIndex(0).setErrorCode(Errors.NONE.code()));
    OffsetDeleteResponseTopicCollection topics = new OffsetDeleteResponseTopicCollection();
    topics.add(new OffsetDeleteResponseTopic().setName("topic1").setPartitions(partitions));
    OffsetDeleteResponseData data = new OffsetDeleteResponseData();
    data.setErrorCode(Errors.NONE.code());
    data.setTopics(topics);
    return new OffsetDeleteResponse(data);
}
Also used : OffsetDeleteResponsePartitionCollection(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponsePartitionCollection) OffsetDeleteResponseTopic(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponseTopic) OffsetDeleteResponsePartition(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponsePartition) OffsetDeleteResponseTopicCollection(org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponseTopicCollection) OffsetDeleteResponseData(org.apache.kafka.common.message.OffsetDeleteResponseData)

Aggregations

OffsetDeleteResponseData (org.apache.kafka.common.message.OffsetDeleteResponseData)2 OffsetDeleteResponsePartition (org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponsePartition)2 OffsetDeleteResponsePartitionCollection (org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponsePartitionCollection)2 OffsetDeleteResponseTopic (org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponseTopic)2 OffsetDeleteResponseTopicCollection (org.apache.kafka.common.message.OffsetDeleteResponseData.OffsetDeleteResponseTopicCollection)2 TopicPartition (org.apache.kafka.common.TopicPartition)1 OffsetDeleteResponse (org.apache.kafka.common.requests.OffsetDeleteResponse)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1