Preethi-Sundaravelu commented on code in PR #21826:
URL: https://github.com/apache/kafka/pull/21826#discussion_r3671111831


##########
tools/src/test/java/org/apache/kafka/tools/StreamsResetterTest.java:
##########
@@ -431,4 +432,135 @@ public synchronized Map<TopicPartition, 
OffsetAndTimestamp> offsetsForTimes(fina
             return topicPartitionToOffsetAndTimestamp;
         }
     }
+
+    @Test
+    public void shouldFailIfApplicationIdDoesNotExistAsConsumerGroup() throws 
Exception {
+        final String groupId = "my-app";
+
+        final Admin adminClient = mock(Admin.class);
+        final DescribeConsumerGroupsResult describeResult = 
mock(DescribeConsumerGroupsResult.class);
+
+        final KafkaFutureImpl<Map<String, ConsumerGroupDescription>> future = 
new KafkaFutureImpl<>();
+        future.completeExceptionally(new GroupIdNotFoundException("Group " + 
groupId + " not found."));
+
+        when(describeResult.all()).thenReturn(future);
+        
when(adminClient.describeConsumerGroups(Set.of(groupId))).thenReturn(describeResult);
+
+        assertThrows(IllegalArgumentException.class,
+                () -> streamsResetter.validateApplicationIdExists(groupId, 
adminClient));
+    }
+
+    @Test
+    public void shouldSucceedIfApplicationIdExistsAsConsumerGroup() throws 
Exception {
+        final String groupId = "my-app-v1";
+
+        final Admin adminClient = mock(Admin.class);
+        final DescribeConsumerGroupsResult describeResult = 
mock(DescribeConsumerGroupsResult.class);
+        final ConsumerGroupDescription stableDescription = 
mock(ConsumerGroupDescription.class);
+
+        when(stableDescription.groupState()).thenReturn(GroupState.STABLE);
+
+        final KafkaFutureImpl<Map<String, ConsumerGroupDescription>> future = 
new KafkaFutureImpl<>();
+        future.complete(Map.of(groupId, stableDescription));
+
+        when(describeResult.all()).thenReturn(future);
+        
when(adminClient.describeConsumerGroups(Set.of(groupId))).thenReturn(describeResult);
+
+        streamsResetter.validateApplicationIdExists(groupId, adminClient);
+    }
+
+    @Test
+    public void shouldFailIfNoConsumerGroupsExistAtAll() throws Exception {
+        final String groupId = "my-app";
+
+        final Admin adminClient = mock(Admin.class);
+        final DescribeConsumerGroupsResult describeResult = 
mock(DescribeConsumerGroupsResult.class);
+
+        final KafkaFutureImpl<Map<String, ConsumerGroupDescription>> future = 
new KafkaFutureImpl<>();
+        future.completeExceptionally(new GroupIdNotFoundException("Group " + 
groupId + " not found."));
+
+        when(describeResult.all()).thenReturn(future);
+        
when(adminClient.describeConsumerGroups(Set.of(groupId))).thenReturn(describeResult);
+
+        assertThrows(IllegalArgumentException.class,
+                () -> streamsResetter.validateApplicationIdExists(groupId, 
adminClient));
+    }
+
+    @Test
+    public void shouldFailIfApplicationIdIsAPrefixOfExistingGroup() throws 
Exception {

Review Comment:
   This has been taken care, I have removed the duplicate test



-- 
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]

Reply via email to