8000 Step 2: Flux complete · blackbeltcoder/reactive-spring@f7da8ff · GitHub
[go: up one dir, main page]

Skip to content

Commit f7da8ff

Browse files
committed
Step 2: Flux complete
1 parent e3600e1 commit f7da8ff

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

reactor/src/test/java/workshop/Step2Flux.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public class Step2Flux {
35< 8000 /code>35
@Test
3636
public void verifyFluxEmission() {
3737

38-
// TODO: Replace this line by creating a Flux that publishes "Skyler" and "Walter" elements
39-
Flux<String> flux = Flux.empty();
38+
Flux<String> flux = Flux.just("Skyler", "Walter");
4039

4140
StepVerifier.create(flux).expectNext("Skyler", "Walter").verifyComplete();
4241
}
@@ -46,8 +45,7 @@ public void verifyInfiniteStreamEmission() {
4645

4746
Stream<Double> stream = Stream.generate(Math::random);
4847

49-
// TODO: Replace this line by creating a Flux that generates values from a Java 8 Stream
50-
Flux<Double> flux = Flux.empty();
48+
Flux<Double> flux = Flux.fromStream(stream);
5149

5250
StepVerifier.create(flux).expectNextCount(5).thenCancel().verify();
5351
}
@@ -57,8 +55,7 @@ public void fluxShouldCreateHelloWorldFromIterable() {
5755

5856
List<String> strings = Arrays.asList("Saul", "Mike");
5957

60-
// TODO: Replace this line by creating a Flux from a resolved collection
61-
Flux<String> flux = Flux.empty();
58+
Flux<String> flux = Flux.fromIterable(strings);
6259

6360
StepVerifier.create(flux).expectNext("Saul", "Mike").verifyComplete();
6461
}
@@ -68,8 +65,7 @@ public void fluxShouldEmitItemsOverTime() {
6865

6966
Duration duration = Duration.ofSeconds(2);
7067

71-
// TODO: Replace this line by creating a Flux publishing items over time
72-
Flux<Long> flux = Flux.empty();
68+
Flux<Long> flux = Flux.interval(duration);
7369

7470
StepVerifier.create(flux.doOnNext(System.out::println).take(4)).expectNext(0L, 1L, 2L, 3L).verifyComplete();
7571
}

0 commit comments

Comments
 (0)
0