chia7712 commented on code in PR #20096: URL: https://github.com/apache/kafka/pull/20096#discussion_r2252170199
########## tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java: ########## @@ -236,9 +236,9 @@ public void testParseAssignmentPartitionsOfDifferentSize() { public void testParseAssignment() { Map<Integer, List<Integer>> actualAssignment = TopicCommand.parseReplicaAssignment("5:4,3:2,1:0"); Map<Integer, List<Integer>> expectedAssignment = new HashMap<>(); - expectedAssignment.put(0, Arrays.asList(5, 4)); - expectedAssignment.put(1, Arrays.asList(3, 2)); - expectedAssignment.put(2, Arrays.asList(1, 0)); + expectedAssignment.put(0, List.of(5, 4)); Review Comment: Could you please remove the redundant "space" ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -378,7 +375,7 @@ public void testRetrieveInternalTopics() { public void testDeleteStreamsGroup() { Admin adminClient = mock(KafkaAdminClient.class); String groupId = "foo-group"; - List<String> args = new ArrayList<>(Arrays.asList("--bootstrap-server", "localhost:9092", "--group", groupId, "--delete", "--delete-all-internal-topics")); + List<String> args = new ArrayList<>(List.of("--bootstrap-server", "localhost:9092", "--group", groupId, "--delete", "--delete-all-internal-topics")); Review Comment: ditto ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -297,7 +294,7 @@ public void testGroupStatesFromString() { public void testAdminRequestsForResetOffsets() { Admin adminClient = mock(KafkaAdminClient.class); String groupId = "foo-group"; - List<String> args = new ArrayList<>(Arrays.asList("--bootstrap-server", "localhost:9092", "--group", groupId, "--reset-offsets", "--input-topic", "topic1", "--to-latest")); + List<String> args = new ArrayList<>(List.of("--bootstrap-server", "localhost:9092", "--group", groupId, "--reset-offsets", "--input-topic", "topic1", "--to-latest")); Review Comment: ditto ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -124,19 +121,19 @@ public void testListStreamsGroupsWithStates() throws Exception { String[] cgcArgs = new String[]{"--bootstrap-server", BOOTSTRAP_SERVERS, "--list", "--state"}; ListGroupsResult resultWithAllStates = mock(ListGroupsResult.class); - when(resultWithAllStates.all()).thenReturn(KafkaFuture.completedFuture(Arrays.asList( + when(resultWithAllStates.all()).thenReturn(KafkaFuture.completedFuture(List.of( new GroupListing(firstGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.STABLE)), new GroupListing(secondGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.EMPTY)) ))); when(ADMIN_CLIENT.listGroups(any(ListGroupsOptions.class))).thenReturn(resultWithAllStates); StreamsGroupCommand.StreamsGroupService service = getStreamsGroupService(cgcArgs); - Set<GroupListing> expectedListing = new HashSet<>(Arrays.asList( + Set<GroupListing> expectedListing = new HashSet<>(List.of( new GroupListing(firstGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.STABLE)), new GroupListing(secondGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.EMPTY)))); final Set[] foundListing = new Set[]{Set.of()}; TestUtils.waitForCondition(() -> { - foundListing[0] = new HashSet<>(service.listStreamsGroupsInStates(new HashSet<>(Arrays.asList(GroupState.values())))); + foundListing[0] = new HashSet<>(service.listStreamsGroupsInStates(new HashSet<>(List.of(GroupState.values())))); Review Comment: ditto ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -124,19 +121,19 @@ public void testListStreamsGroupsWithStates() throws Exception { String[] cgcArgs = new String[]{"--bootstrap-server", BOOTSTRAP_SERVERS, "--list", "--state"}; ListGroupsResult resultWithAllStates = mock(ListGroupsResult.class); - when(resultWithAllStates.all()).thenReturn(KafkaFuture.completedFuture(Arrays.asList( + when(resultWithAllStates.all()).thenReturn(KafkaFuture.completedFuture(List.of( new GroupListing(firstGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.STABLE)), new GroupListing(secondGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.EMPTY)) ))); when(ADMIN_CLIENT.listGroups(any(ListGroupsOptions.class))).thenReturn(resultWithAllStates); StreamsGroupCommand.StreamsGroupService service = getStreamsGroupService(cgcArgs); - Set<GroupListing> expectedListing = new HashSet<>(Arrays.asList( + Set<GroupListing> expectedListing = new HashSet<>(List.of( Review Comment: ditto ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -332,7 +329,7 @@ public void testAdminRequestsForResetOffsets() { @Test public void testRetrieveInternalTopics() { String groupId = "foo-group"; - List<String> args = new ArrayList<>(Arrays.asList("--bootstrap-server", "localhost:9092", "--group", groupId, "--delete")); + List<String> args = new ArrayList<>(List.of("--bootstrap-server", "localhost:9092", "--group", groupId, "--delete")); Review Comment: we don't need to covert it to an `ArrayList` ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -91,13 +90,13 @@ public void testListStreamsGroups() throws Exception { String[] cgcArgs = new String[]{"--bootstrap-server", BOOTSTRAP_SERVERS, "--list"}; ListGroupsResult result = mock(ListGroupsResult.class); - when(result.all()).thenReturn(KafkaFuture.completedFuture(Arrays.asList( + when(result.all()).thenReturn(KafkaFuture.completedFuture(List.of( new GroupListing(firstGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.STABLE)), new GroupListing(secondGroup, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.EMPTY)) ))); when(ADMIN_CLIENT.listGroups(any(ListGroupsOptions.class))).thenReturn(result); StreamsGroupCommand.StreamsGroupService service = getStreamsGroupService(cgcArgs); - Set<String> expectedGroups = new HashSet<>(Arrays.asList(firstGroup, secondGroup)); + Set<String> expectedGroups = new HashSet<>(List.of(firstGroup, secondGroup)); Review Comment: Would using `Set.of` work here? ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -409,7 +406,7 @@ public void testDeleteStreamsGroup() { public void testDeleteNonStreamsGroup() { Admin adminClient = mock(KafkaAdminClient.class); String groupId = "foo-group"; - List<String> args = new ArrayList<>(Arrays.asList("--bootstrap-server", "localhost:9092", "--group", groupId, "--delete")); + List<String> args = new ArrayList<>(List.of("--bootstrap-server", "localhost:9092", "--group", groupId, "--delete")); Review Comment: ditto ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -450,7 +447,7 @@ StreamsGroupCommand.StreamsGroupService getStreamsGroupService(String[] args, Ad } private static void assertThrow(final String wrongState) { - final Set<String> validStates = new HashSet<>(Arrays.asList("Assigning", "Dead", "Empty", "Reconciling", "Stable", "NotReady")); + final Set<String> validStates = new HashSet<>(List.of("Assigning", "Dead", "Empty", "Reconciling", "Stable", "NotReady")); Review Comment: ditto ########## tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java: ########## @@ -257,7 +257,7 @@ public void testCreateTopicDoesNotRetryThrottlingQuotaExceededException() { }))); NewTopic expectedNewTopic = new NewTopic(topicName, Optional.empty(), Optional.empty()) - .configs(Collections.emptyMap()); + .configs(Map.of()); Review Comment: the assignment is unnecessary, as the default value is `null`, which is equivalent to being empty. ########## tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java: ########## @@ -317,7 +314,7 @@ public void testAdminRequestsForResetOffsets() { StreamsGroupCommand.StreamsGroupService service = getStreamsGroupService(args.toArray(new String[0]), adminClient); Map<String, Map<TopicPartition, OffsetAndMetadata>> resetResult = service.resetOffsets(); - assertEquals(Collections.singleton(groupId), resetResult.keySet()); + assertEquals(Set.of(groupId), resetResult.keySet()); assertEquals(new HashSet<>(List.of(new TopicPartition(topics.get(0), 0))), Review Comment: ditto -- 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