diff --git a/common/src/test/java/org/astraea/common/admin/AdminTest.java b/common/src/test/java/org/astraea/common/admin/AdminTest.java index 7aae77d860..6eb766ecdf 100644 --- a/common/src/test/java/org/astraea/common/admin/AdminTest.java +++ b/common/src/test/java/org/astraea/common/admin/AdminTest.java @@ -359,7 +359,7 @@ void testOrder() { .sorted( Comparator.comparing(Replica::topic) .thenComparing(Replica::partition) - .thenComparing(r -> r.brokerId())) + .thenComparing(Replica::brokerId)) .collect(Collectors.toList()), replicas); } @@ -849,8 +849,7 @@ void testCreateTopicWithReplicasAssignment() { var config = admin.topics(Set.of(topic)).toCompletableFuture().join().get(0).config(); var partitions = - admin.partitions(Set.of(topic)).toCompletableFuture().join().stream() - .collect(Collectors.toUnmodifiableList()); + admin.partitions(Set.of(topic)).toCompletableFuture().join().stream().toList(); Assertions.assertTrue(config.raw().containsValue("lz4")); Assertions.assertEquals( List.of(0, 2), @@ -999,7 +998,6 @@ void testConsumerGroups() { .forEach( c -> { Assertions.assertNotNull(c.groupId()); - Assertions.assertNotNull(c.coordinatorId()); Assertions.assertNotNull(c.assignor()); Assertions.assertNotNull(c.state()); }); @@ -1249,7 +1247,7 @@ void testCompact() { IntStream.range(0, 5) .mapToObj(i -> consumer.poll(Duration.ofSeconds(1))) .flatMap(FixedIterable::stream) - .collect(Collectors.toList()); + .toList(); Assertions.assertEquals( 1, records.stream().filter(record -> record.key().equals(key)).count()); @@ -1354,8 +1352,7 @@ void testReplicasPreferredLeaderFlag() { .collect( Collectors.groupingBy( replica -> TopicPartition.of(replica.topic(), replica.partition()), - Collectors.mapping( - replica -> replica.brokerId(), Collectors.toList()))); + Collectors.mapping(Replica::brokerId, Collectors.toList()))); IntStream.range(0, partitionCount) .forEach(p -> admin.moveToBrokers(Map.of(TopicPartition.of(topic, p), List.of(0, 1, 2)))); @@ -1381,10 +1378,7 @@ void testProducerStates() { .toCompletableFuture() .join(); Assertions.assertNotEquals(0, states.size()); - var producerState = - states.stream() - .filter(s -> s.topic().equals(topic)) - .collect(Collectors.toUnmodifiableList()); + var producerState = states.stream().filter(s -> s.topic().equals(topic)).toList(); Assertions.assertEquals(1, producerState.size()); } } @@ -1397,7 +1391,7 @@ void testConnectionQuotas() { var quotas = admin.quotas(Set.of(QuotaConfigs.IP)).toCompletableFuture().join().stream() .filter(q -> q.targetValue().equals(Utils.hostname())) - .collect(Collectors.toList()); + .toList(); Assertions.assertNotEquals(0, quotas.size()); quotas.forEach( quota -> { @@ -1431,7 +1425,7 @@ void testProducerQuotas() { admin.quotas(Set.of(QuotaConfigs.CLIENT_ID)).toCompletableFuture().join().stream() .filter(q -> q.targetValue().equals(Utils.hostname())) .filter(q -> q.limitKey().equals(QuotaConfigs.PRODUCER_BYTE_RATE_CONFIG)) - .collect(Collectors.toList()); + .toList(); Assertions.assertNotEquals(0, quotas.size()); quotas.forEach( quota -> Assertions.assertEquals(DataRate.Byte.of(100).byteRate(), quota.limitValue())); @@ -1461,7 +1455,7 @@ void testConsumerQuotas() { admin.quotas(Set.of(QuotaConfigs.CLIENT_ID)).toCompletableFuture().join().stream() .filter(q -> q.targetValue().equals(Utils.hostname())) .filter(q -> q.limitKey().equals(QuotaConfigs.CONSUMER_BYTE_RATE_CONFIG)) - .collect(Collectors.toList()); + .toList(); Assertions.assertNotEquals(0, quotas.size()); quotas.forEach( quota -> Assertions.assertEquals(DataRate.Byte.of(1000).byteRate(), quota.limitValue())); @@ -1564,8 +1558,7 @@ void testDeleteRecord() { @Test void testDeleteTopic() { - var topic = - IntStream.range(0, 4).mapToObj(x -> Utils.randomString()).collect(Collectors.toList()); + var topic = IntStream.range(0, 4).mapToObj(x -> Utils.randomString()).toList(); try (var admin = Admin.of(SERVICE.bootstrapServers())) { topic.forEach( @@ -1645,7 +1638,7 @@ void testDeleteMembers() { .toCompletableFuture() .join(); } - String groupId = null; + String groupId; try (var consumer = Consumer.forTopics(Set.of(topic)) .bootstrapServers(SERVICE.bootstrapServers()) @@ -1675,7 +1668,7 @@ void testDeleteGroups() { .toCompletableFuture() .join(); } - String groupId = null; + String groupId; try (var consumer = Consumer.forTopics(Set.of(topic)) .bootstrapServers(SERVICE.bootstrapServers())