Merge pull request #30281 from Captain1653/unchecked-cast
Remove unchecked cast from SourceTest and FlowTest
This commit is contained in:
commit
7f3bfb1a30
2 changed files with 16 additions and 32 deletions
|
|
@ -32,6 +32,7 @@ import java.util.concurrent.CompletionStage;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
|
|
@ -290,7 +291,6 @@ public class FlowTest extends StreamTest {
|
||||||
probe.expectMsgEquals(6);
|
probe.expectMsgEquals(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToUseGroupBy() throws Exception {
|
public void mustBeAbleToUseGroupBy() throws Exception {
|
||||||
final Iterable<String> input = Arrays.asList("Aaa", "Abb", "Bcc", "Cdd", "Cee");
|
final Iterable<String> input = Arrays.asList("Aaa", "Abb", "Bcc", "Cdd", "Cee");
|
||||||
|
|
@ -308,22 +308,14 @@ public class FlowTest extends StreamTest {
|
||||||
|
|
||||||
final CompletionStage<List<List<String>>> future =
|
final CompletionStage<List<List<String>>> future =
|
||||||
Source.from(input).via(flow).limit(10).runWith(Sink.seq(), system);
|
Source.from(input).via(flow).limit(10).runWith(Sink.seq(), system);
|
||||||
final Object[] result = future.toCompletableFuture().get(1, TimeUnit.SECONDS).toArray();
|
final List<List<String>> result =
|
||||||
Arrays.sort(
|
future.toCompletableFuture().get(1, TimeUnit.SECONDS).stream()
|
||||||
result,
|
.sorted(Comparator.comparingInt(list -> list.get(0).charAt(0)))
|
||||||
(Comparator<Object>)
|
.collect(Collectors.toList());
|
||||||
(Object)
|
|
||||||
new Comparator<List<String>>() {
|
|
||||||
@Override
|
|
||||||
public int compare(List<String> o1, List<String> o2) {
|
|
||||||
return o1.get(0).charAt(0) - o2.get(0).charAt(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assertArrayEquals(
|
assertEquals(
|
||||||
new Object[] {
|
Arrays.asList(
|
||||||
Arrays.asList("Aaa", "Abb"), Arrays.asList("Bcc"), Arrays.asList("Cdd", "Cee")
|
Arrays.asList("Aaa", "Abb"), Arrays.asList("Bcc"), Arrays.asList("Cdd", "Cee")),
|
||||||
},
|
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.CompletionStage;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
@ -177,7 +178,6 @@ public class SourceTest extends StreamTest {
|
||||||
probe.expectMsgEquals(6);
|
probe.expectMsgEquals(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToUseGroupBy() throws Exception {
|
public void mustBeAbleToUseGroupBy() throws Exception {
|
||||||
final Iterable<String> input = Arrays.asList("Aaa", "Abb", "Bcc", "Cdd", "Cee");
|
final Iterable<String> input = Arrays.asList("Aaa", "Abb", "Bcc", "Cdd", "Cee");
|
||||||
|
|
@ -195,22 +195,14 @@ public class SourceTest extends StreamTest {
|
||||||
|
|
||||||
final CompletionStage<List<List<String>>> future =
|
final CompletionStage<List<List<String>>> future =
|
||||||
source.grouped(10).runWith(Sink.head(), system);
|
source.grouped(10).runWith(Sink.head(), system);
|
||||||
final Object[] result = future.toCompletableFuture().get(1, TimeUnit.SECONDS).toArray();
|
final List<List<String>> result =
|
||||||
Arrays.sort(
|
future.toCompletableFuture().get(1, TimeUnit.SECONDS).stream()
|
||||||
result,
|
.sorted(Comparator.comparingInt(list -> list.get(0).charAt(0)))
|
||||||
(Comparator<Object>)
|
.collect(Collectors.toList());
|
||||||
(Object)
|
|
||||||
new Comparator<List<String>>() {
|
|
||||||
@Override
|
|
||||||
public int compare(List<String> o1, List<String> o2) {
|
|
||||||
return o1.get(0).charAt(0) - o2.get(0).charAt(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assertArrayEquals(
|
assertEquals(
|
||||||
new Object[] {
|
Arrays.asList(
|
||||||
Arrays.asList("Aaa", "Abb"), Arrays.asList("Bcc"), Arrays.asList("Cdd", "Cee")
|
Arrays.asList("Aaa", "Abb"), Arrays.asList("Bcc"), Arrays.asList("Cdd", "Cee")),
|
||||||
},
|
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue