lianetm commented on code in PR #22425: URL: https://github.com/apache/kafka/pull/22425#discussion_r3381970152
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractHeartbeatRequestManagerTest.java: ########## @@ -0,0 +1,334 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.clients.consumer.internals; + +import org.apache.kafka.clients.ClientResponse; +import org.apache.kafka.clients.consumer.internals.events.BackgroundEventHandler; +import org.apache.kafka.clients.consumer.internals.events.ErrorEvent; +import org.apache.kafka.common.protocol.Errors; +import org.apache.kafka.common.requests.AbstractResponse; +import org.apache.kafka.common.utils.Time; +import org.apache.kafka.common.utils.Timer; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.ArgumentCaptor; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +abstract class AbstractHeartbeatRequestManagerTest { + + protected static final String DEFAULT_GROUP_ID = "groupId"; + protected static final String DEFAULT_MEMBER_ID = "member-id"; + protected static final int DEFAULT_MEMBER_EPOCH = 1; + protected static final int DEFAULT_HEARTBEAT_INTERVAL_MS = 1000; + protected static final int DEFAULT_MAX_POLL_INTERVAL_MS = 10000; + protected static final long DEFAULT_RETRY_BACKOFF_MS = 80; + protected static final long DEFAULT_RETRY_BACKOFF_MAX_MS = 1000; + protected static final double DEFAULT_HEARTBEAT_JITTER_MS = 0.0; + + protected Time time; + protected Timer pollTimer; + protected CoordinatorRequestManager coordinatorRequestManager; + protected SubscriptionState subscriptions; + protected BackgroundEventHandler backgroundEventHandler; + protected HeartbeatRequestState heartbeatRequestState; + protected AbstractMembershipManager membershipManager; + protected AbstractHeartbeatRequestManager heartbeatRequestManager; + + protected abstract ClientResponse createHeartbeatResponse( + NetworkClientDelegate.UnsentRequest request, Errors error); + + // --------------------------------------------------------------------------------------- + // Inherited tests - these exercise behavior implemented in AbstractHeartbeatRequestManager + // and therefore must produce the same outcome for every concrete subclass. + // --------------------------------------------------------------------------------------- Review Comment: should we move this to a class-level java doc? -- 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]
