+ 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:
parent
39c97c3306
commit
e44fafd4b7
12 changed files with 204 additions and 15 deletions
|
|
@ -10,6 +10,7 @@ import akka.japi.JavaPartialFunction;
|
|||
import akka.japi.Pair;
|
||||
import akka.japi.function.*;
|
||||
import akka.stream.*;
|
||||
import akka.stream.scaladsl.FlowSpec;
|
||||
import akka.util.ConstantFun;
|
||||
import akka.stream.javadsl.GraphDSL.Builder;
|
||||
import akka.stream.stage.*;
|
||||
|
|
@ -192,13 +193,13 @@ public class FlowTest extends StreamTest {
|
|||
|
||||
public final Inlet<Integer> in = Inlet.create("in");
|
||||
public final Outlet<Integer> out = Outlet.create("out");
|
||||
|
||||
|
||||
@Override
|
||||
public GraphStageLogic createLogic(Attributes inheritedAttributes) throws Exception {
|
||||
return new GraphStageLogic(shape()) {
|
||||
int sum = 0;
|
||||
int count = 0;
|
||||
|
||||
|
||||
{
|
||||
setHandler(in, new AbstractInHandler() {
|
||||
@Override
|
||||
|
|
@ -211,7 +212,7 @@ public class FlowTest extends StreamTest {
|
|||
} else {
|
||||
emitMultiple(out, Arrays.asList(element, element).iterator());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
setHandler(out, new AbstractOutHandler() {
|
||||
|
|
@ -223,14 +224,14 @@ public class FlowTest extends StreamTest {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FlowShape<Integer, Integer> shape() {
|
||||
return FlowShape.of(in, out);
|
||||
}
|
||||
}
|
||||
);
|
||||
Source.from(input).via(flow).runForeach((Procedure<Integer>) elem ->
|
||||
Source.from(input).via(flow).runForeach((Procedure<Integer>) elem ->
|
||||
probe.getRef().tell(elem, ActorRef.noSender()), materializer);
|
||||
|
||||
probe.expectMsgEquals(0);
|
||||
|
|
@ -315,7 +316,7 @@ public class FlowTest extends StreamTest {
|
|||
return new GraphStage<FlowShape<T, T>>() {
|
||||
public final Inlet<T> in = Inlet.create("in");
|
||||
public final Outlet<T> out = Outlet.create("out");
|
||||
|
||||
|
||||
@Override
|
||||
public GraphStageLogic createLogic(Attributes inheritedAttributes) throws Exception {
|
||||
return new GraphStageLogic(shape()) {
|
||||
|
|
@ -682,6 +683,16 @@ public class FlowTest extends StreamTest {
|
|||
probe.expectMsgEquals("C");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustBeAbleToUseCollectType() throws Exception {
|
||||
final TestKit probe = new TestKit(system);
|
||||
final Iterable<FlowSpec.Fruit> input = Arrays.asList(new FlowSpec.Apple(), new FlowSpec.Orange());
|
||||
|
||||
Source.from(input).via(Flow.of(FlowSpec.Fruit.class).collectType(FlowSpec.Apple.class))
|
||||
.runForeach((apple) -> probe.getRef().tell(apple, ActorRef.noSender()), materializer);
|
||||
probe.expectMsgAnyClassOf(FlowSpec.Apple.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustBeAbleToRecover() throws Exception {
|
||||
final TestPublisher.ManualProbe<Integer> publisherProbe = TestPublisher.manualProbe(true,system);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue