Parkerhiphop commented on code in PR #19213: URL: https://github.com/apache/kafka/pull/19213#discussion_r2008773819
########## 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); + + String capturedOutput = ToolsTestUtils.captureStandardOut(() -> { + try { + service.alterClientMetrics(new ClientMetricsCommand.ClientMetricsCommandOptions( + new String[]{"--bootstrap-server", bootstrapServer, "--alter", + "--name", clientMetricsName, "--metrics", "", + "--interval", "", "--match", ""})); + } catch (Throwable t) { + fail(t); + } + }); + Map<ConfigResource, Collection<AlterConfigOp>> alteredConfigOps = configCaptor.getValue(); + assertTrue(alteredConfigOps != null, "alteredConfigOps should not be null"); + assertEquals(1, alteredConfigOps.size(), "Should have exactly one ConfigResource"); + + Collection<AlterConfigOp> operations = alteredConfigOps.values().iterator().next(); + assertEquals(3, operations.size(), "Should have exactly 3 operations"); + for (Collection<AlterConfigOp> ops : alteredConfigOps.values()) { Review Comment: @chia7712 Thanks for pointing it out, I've updated the test accordingly. -- 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