lianetm commented on code in PR #16312:
URL: https://github.com/apache/kafka/pull/16312#discussion_r1645037904
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/MembershipManagerImplTest.java:
##########
@@ -81,53 +82,47 @@
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anySet;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@SuppressWarnings("ClassDataAbstractionCoupling")
public class MembershipManagerImplTest {
private static final String GROUP_ID = "test-group";
private static final String MEMBER_ID = "test-member-1";
private static final int REBALANCE_TIMEOUT = 100;
private static final int MEMBER_EPOCH = 1;
- private final LogContext logContext = new LogContext();
+ private LogContext logContext;
private SubscriptionState subscriptionState;
private ConsumerMetadata metadata;
-
private CommitRequestManager commitRequestManager;
-
- private ConsumerTestBuilder testBuilder;
private BlockingQueue<BackgroundEvent> backgroundEventQueue;
private BackgroundEventHandler backgroundEventHandler;
private Time time;
private Metrics metrics;
private RebalanceMetricsManager rebalanceMetricsManager;
+ @SuppressWarnings("unchecked")
@BeforeEach
public void setup() {
- testBuilder = new
ConsumerTestBuilder(ConsumerTestBuilder.createDefaultGroupInformation());
- metadata = testBuilder.metadata;
- subscriptionState = testBuilder.subscriptions;
- commitRequestManager =
testBuilder.commitRequestManager.orElseThrow(IllegalStateException::new);
- backgroundEventQueue = testBuilder.backgroundEventQueue;
- backgroundEventHandler = testBuilder.backgroundEventHandler;
+ metadata = mock(ConsumerMetadata.class);
+ subscriptionState = mock(SubscriptionState.class);
+ commitRequestManager = mock(CommitRequestManager.class);
+ backgroundEventHandler = mock(BackgroundEventHandler.class);
+ backgroundEventQueue = mock(BlockingQueue.class);
Review Comment:
heads-up, having these as mocks means we cannot retrieve the events like we
used to (backgroundEventQueue.poll), that I notice is still used to get the
event to `performCallback`. I would say having it as a mock is the right thing
to do, but we need to fix how we get the events from it. Ex.
[this](https://github.com/apache/kafka/blob/53ec9733c2bf8b122fbd193d8d00b8e25cbd648f/clients/src/test/java/org/apache/kafka/clients/consumer/internals/MembershipManagerImplTest.java#L2165-L2169)
section to get the callback event to complete should be updated to retrieve
the event with an argument captor instead (similar to how it's done
[here](https://github.com/apache/kafka/blob/f2a552a1ebaa0ce933f90343655b63e2472856d9/clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java#L807-L809),
but retrieving a `ConsumerRebalanceListenerCallbackNeededEvent`)
--
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]