kirktrue commented on code in PR #20521:
URL: https://github.com/apache/kafka/pull/20521#discussion_r2487422954
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessorTest.java:
##########
@@ -660,6 +662,71 @@ public void
testStreamsOnAllTasksLostCallbackCompletedEventWithoutStreamsMembers
}
}
+ @Test
+ public void testUpdatePatternSubscriptionInvokedWhenMetadataUpdated() {
+ when(subscriptionState.hasPatternSubscription()).thenReturn(true);
+
when(subscriptionState.matchesSubscribedPattern(any(String.class))).thenReturn(true);
+ when(metadata.updateVersion()).thenReturn(1, 2);
+ testUpdatePatternSubscription(times(1));
+ }
+
+ @Test
+ public void
testUpdatePatternSubscriptionNotInvokedWhenNotUsingPatternSubscription() {
+ when(subscriptionState.hasPatternSubscription()).thenReturn(false);
+ when(metadata.updateVersion()).thenReturn(1, 2);
+ testUpdatePatternSubscription(never());
+ }
+
+ @Test
+ public void
testUpdatePatternSubscriptionNotInvokedWhenMetadataNotUpdated() {
+ when(subscriptionState.hasPatternSubscription()).thenReturn(true);
+
when(subscriptionState.matchesSubscribedPattern(any(String.class))).thenReturn(true);
+ when(metadata.updateVersion()).thenReturn(1, 1);
+ testUpdatePatternSubscription(never());
+ }
+
+ private void testUpdatePatternSubscription(VerificationMode
verificationMode) {
+ String topic = "test-topic";
+ Cluster cluster = mock(Cluster.class);
+
+ when(metadata.fetch()).thenReturn(cluster);
+ when(cluster.topics()).thenReturn(Set.of(topic));
+
+
when(heartbeatRequestManager.membershipManager()).thenReturn(membershipManager);
+
when(offsetsRequestManager.updateFetchPositions(anyLong())).thenReturn(CompletableFuture.completedFuture(true));
+
+ setupProcessor(true);
+ processor.process(new AsyncPollEvent(110, 100));
+ verify(membershipManager, verificationMode).onSubscriptionUpdated();
Review Comment:
Added check for `matchesSubscriptionPattern()`, as requested.
--
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]