showuon commented on a change in pull request #11019:
URL: https://github.com/apache/kafka/pull/11019#discussion_r670111886
##########
File path:
clients/src/test/java/org/apache/kafka/clients/admin/internals/DeleteConsumerGroupOffsetsHandlerTest.java
##########
@@ -67,48 +69,88 @@ public void testBuildRequest() {
@Test
public void testSuccessfulHandleResponse() {
Map<TopicPartition, Errors> responseData =
Collections.singletonMap(t0p0, Errors.NONE);
- assertCompleted(handleWithError(Errors.NONE), responseData);
+ assertCompleted(handleWithGroupError(Errors.NONE), responseData);
}
@Test
public void testUnmappedHandleResponse() {
- assertUnmapped(handleWithError(Errors.NOT_COORDINATOR));
+ assertUnmapped(handleWithGroupError(Errors.NOT_COORDINATOR));
+ assertUnmapped(handleWithGroupError(Errors.COORDINATOR_NOT_AVAILABLE));
}
@Test
public void testRetriableHandleResponse() {
- assertRetriable(handleWithError(Errors.COORDINATOR_LOAD_IN_PROGRESS));
- assertRetriable(handleWithError(Errors.COORDINATOR_NOT_AVAILABLE));
+
assertRetriable(handleWithGroupError(Errors.COORDINATOR_LOAD_IN_PROGRESS));
}
@Test
- public void testFailedHandleResponse() {
- assertFailed(GroupAuthorizationException.class,
handleWithError(Errors.GROUP_AUTHORIZATION_FAILED));
- assertFailed(GroupIdNotFoundException.class,
handleWithError(Errors.GROUP_ID_NOT_FOUND));
- assertFailed(InvalidGroupIdException.class,
handleWithError(Errors.INVALID_GROUP_ID));
+ public void testFailedHandleResponseWithGroupError() {
+ assertGroupFailed(GroupAuthorizationException.class,
handleWithGroupError(Errors.GROUP_AUTHORIZATION_FAILED));
+ assertGroupFailed(GroupIdNotFoundException.class,
handleWithGroupError(Errors.GROUP_ID_NOT_FOUND));
+ assertGroupFailed(InvalidGroupIdException.class,
handleWithGroupError(Errors.INVALID_GROUP_ID));
+ assertGroupFailed(GroupNotEmptyException.class,
handleWithGroupError(Errors.NON_EMPTY_GROUP));
}
- private OffsetDeleteResponse buildResponse(Errors error) {
+ @Test
+ public void testFailedHandleResponseWithPartitionError() {
+ assertPartitionFailed(Collections.singletonMap(t0p0,
Errors.GROUP_SUBSCRIBED_TO_TOPIC),
+ handleWithPartitionError(Errors.GROUP_SUBSCRIBED_TO_TOPIC));
+ assertPartitionFailed(Collections.singletonMap(t0p0,
Errors.TOPIC_AUTHORIZATION_FAILED),
+ handleWithPartitionError(Errors.TOPIC_AUTHORIZATION_FAILED));
+ assertPartitionFailed(Collections.singletonMap(t0p0,
Errors.UNKNOWN_TOPIC_OR_PARTITION),
+ handleWithPartitionError(Errors.UNKNOWN_TOPIC_OR_PARTITION));
+ }
+
+ private OffsetDeleteResponse buildGroupErrorResponse(Errors error) {
+ OffsetDeleteResponse response = new OffsetDeleteResponse(
+ new OffsetDeleteResponseData()
+ .setErrorCode(error.code()));
+ if (error == Errors.NONE) {
+ response.data()
+ .setThrottleTimeMs(0)
+ .setTopics(new
OffsetDeleteResponseTopicCollection(singletonList(
+ new OffsetDeleteResponseTopic()
+ .setName(t0p0.topic())
+ .setPartitions(new
OffsetDeleteResponsePartitionCollection(singletonList(
+ new OffsetDeleteResponsePartition()
+ .setPartitionIndex(t0p0.partition())
+ .setErrorCode(error.code())
+ ).iterator()))
+ ).iterator()));
+ }
+ return response;
+ }
+
+ private OffsetDeleteResponse buildPartitionErrorResponse(Errors error) {
OffsetDeleteResponse response = new OffsetDeleteResponse(
- new OffsetDeleteResponseData()
- .setThrottleTimeMs(0)
- .setTopics(new
OffsetDeleteResponseTopicCollection(singletonList(
- new OffsetDeleteResponseTopic()
- .setName("t0")
- .setPartitions(new
OffsetDeleteResponsePartitionCollection(singletonList(
- new OffsetDeleteResponsePartition()
- .setPartitionIndex(0)
- .setErrorCode(error.code())
- ).iterator()))
- ).iterator())));
+ new OffsetDeleteResponseData()
+ .setThrottleTimeMs(0)
+ .setTopics(new
OffsetDeleteResponseTopicCollection(singletonList(
+ new OffsetDeleteResponseTopic()
+ .setName(t0p0.topic())
+ .setPartitions(new
OffsetDeleteResponsePartitionCollection(singletonList(
+ new OffsetDeleteResponsePartition()
+ .setPartitionIndex(t0p0.partition())
+ .setErrorCode(error.code())
+ ).iterator()))
+ ).iterator()))
+ );
Review comment:
indent fix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]