@@ -35,8 +35,7 @@ public class Step2Flux {
35<
8000
/code>
35
@ Test
36
36
public void verifyFluxEmission () {
37
37
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" );
40
39
41
40
StepVerifier .create (flux ).expectNext ("Skyler" , "Walter" ).verifyComplete ();
42
41
}
@@ -46,8 +45,7 @@ public void verifyInfiniteStreamEmission() {
46
45
47
46
Stream <Double > stream = Stream .generate (Math ::random );
48
47
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 );
51
49
52
50
StepVerifier .create (flux ).expectNextCount (5 ).thenCancel ().verify ();
53
51
}
@@ -57,8 +55,7 @@ public void fluxShouldCreateHelloWorldFromIterable() {
57
55
58
56
List <String > strings = Arrays .asList ("Saul" , "Mike" );
59
57
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 );
62
59
63
60
StepVerifier .create (flux ).expectNext ("Saul" , "Mike" ).verifyComplete ();
64
61
}
@@ -68,8 +65,7 @@ public void fluxShouldEmitItemsOverTime() {
68
65
69
66
Duration duration = Duration .ofSeconds (2 );
70
67
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 );
73
69
74
70
StepVerifier .create (flux .doOnNext (System .out ::println ).take (4 )).expectNext (0L , 1L , 2L , 3L ).verifyComplete ();
75
71
}
0 commit comments