chia7712 commented on code in PR #20096:
URL: https://github.com/apache/kafka/pull/20096#discussion_r2229054830
##########
tools/src/test/java/org/apache/kafka/tools/ClusterToolTest.java:
##########
@@ -110,7 +109,7 @@ public void
testListEndpointsWithBootstrapController(ClusterInstance clusterInst
int id = clusterInstance.controllerIds().iterator().next();
String format = "%-10s %-9s %-10s %-10s %-15s%n%-10s %-9s %-10s %-10s
%-10s";
String expected = String.format(format, "ID", "HOST", "PORT", "RACK",
"ENDPOINT_TYPE", id, "localhost", port, "null", "controller");
- assertTrue(output.equals(expected));
+ assertEquals(output, expected);
Review Comment:
`assertEquals(expected, output);`
##########
tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java:
##########
@@ -281,12 +277,12 @@ public void testDynamicBrokerConfigUpdateUsingKraft()
throws Exception {
@ClusterTest
public void testGroupConfigUpdateUsingKraft() throws Exception {
List<String> alterOpts =
Stream.concat(entityOp(Optional.of(defaultGroupName)).stream(),
Review Comment:
```java
List<String> alterOpts =
Stream.concat(entityOp(Optional.of(defaultGroupName)).stream(),
Stream.of("--entity-type", "groups", "--alter")).toList();
```
##########
tools/src/test/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommandTest.java:
##########
@@ -641,7 +641,7 @@ private LogDirReassignment
buildLogDirReassignment(TopicPartition topicPartition
List<Integer> replicas)
throws ExecutionException, InterruptedException {
try (Admin admin =
Admin.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG,
clusterInstance.bootstrapServers()))) {
DescribeLogDirsResult describeLogDirsResult =
admin.describeLogDirs(
Review Comment:
```java
DescribeLogDirsResult describeLogDirsResult =
admin.describeLogDirs(IntStream.range(0, 4).boxed().toList());
```
##########
tools/src/test/java/org/apache/kafka/tools/ConfigCommandTest.java:
##########
@@ -501,31 +500,23 @@ public void shouldFailIfUnresolvableHost() {
}
private Entry<List<String>, Map<String, String>>
argsAndExpectedEntity(Optional<String> entityName, String entityType) {
- String command;
- switch (entityType) {
- case ClientQuotaEntity.USER:
- command = "users";
- break;
- case ClientQuotaEntity.CLIENT_ID:
- command = "clients";
- break;
- case ClientQuotaEntity.IP:
- command = "ips";
- break;
- default:
- throw new IllegalArgumentException("Unknown command: " +
entityType);
- }
+ String command = switch (entityType) {
+ case ClientQuotaEntity.USER -> "users";
+ case ClientQuotaEntity.CLIENT_ID -> "clients";
+ case ClientQuotaEntity.IP -> "ips";
Review Comment:
Could you please replace those constants by `ConfigType`?
##########
tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java:
##########
@@ -352,11 +348,11 @@ private void verifyGroupConfigUpdate(List<String>
alterOpts) throws Exception {
public void testClientMetricsConfigUpdate() throws Exception {
List<String> alterOpts =
Stream.concat(entityOp(Optional.of(defaultClientMetricsName)).stream(),
Review Comment:
```java
List<String> alterOpts =
Stream.concat(entityOp(Optional.of(defaultClientMetricsName)).stream(),
Stream.of("--entity-type", "client-metrics",
"--alter")).toList();
```
##########
tools/src/test/java/org/apache/kafka/tools/streams/StreamsGroupCommandTest.java:
##########
@@ -473,23 +470,23 @@ private DescribeStreamsGroupsResult
describeStreamsResult(String groupId, GroupS
0,
0,
0,
- Collections.singletonList(new
StreamsGroupSubtopologyDescription("subtopologyId", Collections.emptyList(),
Collections.emptyList(), Map.of(), Map.of())),
+ List.of(new StreamsGroupSubtopologyDescription("subtopologyId",
List.of(), List.of(), Map.of(), Map.of())),
List.of(memberDescription),
groupState,
new Node(1, "localhost", 9092),
Set.of());
KafkaFutureImpl<StreamsGroupDescription> future = new
KafkaFutureImpl<>();
future.complete(description);
- return new
DescribeStreamsGroupsResult(Collections.singletonMap(groupId, future));
+ return new DescribeStreamsGroupsResult(Map.of(groupId, future));
}
private DescribeTopicsResult describeTopicsResult(Collection<String>
topics, int numOfPartitions) {
Review Comment:
```java
private DescribeTopicsResult describeTopicsResult(Collection<String>
topics, int numOfPartitions) {
var topicDescriptions =
topics.stream().collect(Collectors.toMap(Function.identity(),
topic -> new TopicDescription(topic, false,
IntStream.range(0, numOfPartitions)
.mapToObj(i -> new TopicPartitionInfo(i, null, List.of(),
List.of()))
.toList())));
return AdminClientTestUtils.describeTopicsResult(topicDescriptions);
}
```
##########
tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupServiceTest.java:
##########
@@ -320,14 +318,14 @@ private DescribeTopicsResult
describeTopicsResult(Collection<String> topics) {
topics.forEach(topic -> {
Review Comment:
```java
private DescribeTopicsResult describeTopicsResult(Collection<String>
topics) {
var topicDescriptions =
topics.stream().collect(Collectors.toMap(Function.identity(),
topic -> new TopicDescription(topic, false,
IntStream.range(0, NUM_PARTITIONS)
.mapToObj(i -> new TopicPartitionInfo(i, Node.noNode(),
List.of(), List.of()))
.toList())));
return AdminClientTestUtils.describeTopicsResult(topicDescriptions);
}
```
--
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]