apoorvmittal10 commented on code in PR #19213:
URL: https://github.com/apache/kafka/pull/19213#discussion_r2006925028


##########
tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:
##########
@@ -367,6 +368,16 @@ public void checkArgs() {
             if (has(alterOpt)) {
                 if ((isNamePresent && has(generateNameOpt)) || (!isNamePresent 
&& !has(generateNameOpt)))
                     throw new IllegalArgumentException("One of --name or 
--generate-name must be specified with --alter.");
+
+                interval().ifPresent(intervalStr -> {
+                    if (!intervalStr.isEmpty()) {
+                        try {
+                            Integer.parseInt(intervalStr);
+                        } catch (NumberFormatException e) {
+                            throw new IllegalArgumentException("Invalid 
interval value. Must be a valid integer or empty to delete the setting.");

Review Comment:
   Can this be better to specify?
   ```suggestion
                               throw new IllegalArgumentException("Invalid 
interval value. Enter an integer, or leave empty to delete.");
   ```



##########
tools/src/test/java/org/apache/kafka/tools/ClientMetricsCommandTest.java:
##########
@@ -156,6 +168,41 @@ public void testAlterGenerateName() {
         assertTrue(capturedOutput.contains("Altered client metrics config"));
     }
 
+    @Test
+    public void testAlterResetConfigs() {
+        Admin adminClient = mock(Admin.class);
+        ClientMetricsCommand.ClientMetricsService service = new 
ClientMetricsCommand.ClientMetricsService(adminClient);
+
+        AlterConfigsResult result = 
AdminClientTestUtils.alterConfigsResult(new 
ConfigResource(ConfigResource.Type.CLIENT_METRICS, clientMetricsName));
+        @SuppressWarnings("unchecked")
+        final ArgumentCaptor<Map<ConfigResource, Collection<AlterConfigOp>>> 
configCaptor = ArgumentCaptor.forClass(Map.class);
+        when(adminClient.incrementalAlterConfigs(configCaptor.capture(), 
any())).thenReturn(result);

Review Comment:
   Query: Can you please help explain regarding what we want to test here?



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to