+ stream add collectType operator to Source,SubSource,Flow and SubFlow for javadsl.

add docs for collectType, do mirror it in scaladsl

mima
This commit is contained in:
虎鸣 2018-01-06 04:33:35 +08:00 committed by Konrad `ktoso` Malawski
parent 39c97c3306
commit e44fafd4b7
12 changed files with 204 additions and 15 deletions

View file

@ -11,8 +11,7 @@ import akka.japi.Pair;
import akka.japi.function.*;
import akka.japi.pf.PFBuilder;
import akka.stream.*;
import akka.stream.testkit.TestSubscriber;
import akka.stream.testkit.javadsl.TestSink;
import akka.stream.scaladsl.FlowSpec;
import akka.util.ConstantFun;
import akka.stream.stage.*;
import akka.testkit.AkkaSpec;
@ -446,6 +445,19 @@ public class SourceTest extends StreamTest {
probe.expectMsgEquals("C");
}
@Test
public void mustBeAbleToUseCollectType() throws Exception{
final TestKit probe = new TestKit(system);
final Iterable<FlowSpec.Apple> input = Collections.singletonList(new FlowSpec.Apple());
final Source<FlowSpec.Apple,?> appleSource = Source.from(input);
final Source<FlowSpec.Fruit,?> fruitSource = appleSource.collectType(FlowSpec.Fruit.class);
fruitSource.collectType(FlowSpec.Apple.class).collectType(FlowSpec.Apple.class)
.runForeach((elem) -> {
probe.getRef().tell(elem,ActorRef.noSender());
},materializer);
probe.expectMsgAnyClassOf(FlowSpec.Apple.class);
}
@Test
public void mustWorkFromFuture() throws Exception {
final Iterable<String> input = Arrays.asList("A", "B", "C");