Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COMMON] fix warnings of AdminTest #1793

Merged
merged 1 commit into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions common/src/test/java/org/astraea/common/admin/AdminTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -999,7 +998,6 @@ void testConsumerGroups() {
.forEach(
c -> {
Assertions.assertNotNull(c.groupId());
Assertions.assertNotNull(c.coordinatorId());
Assertions.assertNotNull(c.assignor());
Assertions.assertNotNull(c.state());
});
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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))));
Expand All @@ -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());
}
}
Expand All @@ -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 -> {
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -1645,7 +1638,7 @@ void testDeleteMembers() {
.toCompletableFuture()
.join();
}
String groupId = null;
String groupId;
try (var consumer =
Consumer.forTopics(Set.of(topic))
.bootstrapServers(SERVICE.bootstrapServers())
Expand Down Expand Up @@ -1675,7 +1668,7 @@ void testDeleteGroups() {
.toCompletableFuture()
.join();
}
String groupId = null;
String groupId;
try (var consumer =
Consumer.forTopics(Set.of(topic))
.bootstrapServers(SERVICE.bootstrapServers())
Expand Down