also fix FlowInterleaveSpec

Also-by: Johan Andrén <johan@markatta.com>
Also-by: Roland Kuhn <rk@rkuhn.info>
Also-by: Martynas Mickevičius <mmartynas@gmail.com>
This commit is contained in:
Endre Sándor Varga 2016-01-20 10:00:37 +02:00 committed by Martynas Mickevičius
parent ef77b56e66
commit 60497f6561
195 changed files with 1110 additions and 857 deletions

View file

@ -9,6 +9,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import akka.NotUsed;
import akka.japi.Pair;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@ -19,7 +20,6 @@ import scala.concurrent.Future;
import scala.concurrent.Promise;
import scala.concurrent.duration.Duration;
import scala.concurrent.duration.FiniteDuration;
import scala.runtime.BoxedUnit;
import scala.Option;
import akka.actor.ActorSystem;
import akka.actor.Cancellable;
@ -48,13 +48,13 @@ public class FlowDocTest {
@Test
public void sourceIsImmutable() throws Exception {
//#source-immutable
final Source<Integer, BoxedUnit> source =
final Source<Integer, NotUsed> source =
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
source.map(x -> 0); // has no effect on source, since it's immutable
source.runWith(Sink.fold(0, (agg, next) -> agg + next), mat); // 55
// returns new Source<Integer>, with `map()` appended
final Source<Integer, BoxedUnit> zeroes = source.map(x -> 0);
final Source<Integer, NotUsed> zeroes = source.map(x -> 0);
final Sink<Integer, Future<Integer>> fold =
Sink.fold(0, (agg, next) -> agg + next);
zeroes.runWith(fold, mat); // 0
@ -70,7 +70,7 @@ public class FlowDocTest {
@Test
public void materializationInSteps() throws Exception {
//#materialization-in-steps
final Source<Integer, BoxedUnit> source =
final Source<Integer, NotUsed> source =
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
// note that the Future is scala.concurrent.Future
final Sink<Integer, Future<Integer>> sink =
@ -91,7 +91,7 @@ public class FlowDocTest {
@Test
public void materializationRunWith() throws Exception {
//#materialization-runWith
final Source<Integer, BoxedUnit> source =
final Source<Integer, NotUsed> source =
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
final Sink<Integer, Future<Integer>> sink =
Sink.fold(0, (aggr, next) -> aggr + next);
@ -195,12 +195,12 @@ public class FlowDocTest {
.to(Sink.foreach(System.out::println));
// Starting from a Source
final Source<Integer, BoxedUnit> source = Source.from(Arrays.asList(1, 2, 3, 4))
final Source<Integer, NotUsed> source = Source.from(Arrays.asList(1, 2, 3, 4))
.map(elem -> elem * 2);
source.to(Sink.foreach(System.out::println));
// Starting from a Sink
final Sink<Integer, BoxedUnit> sink = Flow.of(Integer.class)
final Sink<Integer, NotUsed> sink = Flow.of(Integer.class)
.map(elem -> elem * 2).to(Sink.foreach(System.out::println));
Source.from(Arrays.asList(1, 2, 3, 4)).to(sink);
//#flow-connecting
@ -276,9 +276,9 @@ public class FlowDocTest {
public void fusingAndAsync() {
//#explicit-fusing
Flow<Integer, Integer, BoxedUnit> flow =
Flow<Integer, Integer, NotUsed> flow =
Flow.of(Integer.class).map(x -> x * 2).filter(x -> x > 500);
Graph<FlowShape<Integer, Integer>, BoxedUnit> fused =
Graph<FlowShape<Integer, Integer>, NotUsed> fused =
akka.stream.Fusing.aggressive(flow);
Source.fromIterator(() -> Stream.iterate(0, x -> x + 1).iterator())