8000 Step 4: Transformations complete · blackbeltcoder/reactive-spring@f2d96ab · GitHub
[go: up one dir, main page]

Skip to content

Commit f2d96ab

Browse files
committed
Step 4: Transformations complete
1 parent 51e65eb commit f2d96ab

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

reactor/src/test/java/workshop/Step4Transformations.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public void monoShouldMapValueToUpperCaseHelloWorld() {
3333

3434
Mono<String> mono = Mono.just("Heisenberg");
3535

36-
// TODO: Replace this line to transform the emitted element to uppercase
37-
// mono = …
36+
mono = mono.map(String::toUpperCase);
3837

3938
StepVerifier.create(mono).expectNext("HEISENBERG").verifyComplete();
4039
}
@@ -44,8 +43,7 @@ public void fluxShouldMapValueToUpperCaseHelloWorld() {
4443

4544
Flux<String> flux = Flux.just("Mike", "Gustavo");
4645

47-
// TODO: Replace this line to transform the emitted element to uppercase
48-
// flux = …
46+
flux = flux.map(String::toUpperCase);
4947

5048
StepVerifier.create(flux).expectNext("MIKE", "GUSTAVO").verifyComplete();
5149
}
@@ -55,8 +53,7 @@ public void monoShouldEmitIndividualCharactersAsString() {
5553

5654
Mono<String> mono = Mono.just("Schraderbräu");
5755

58-
// TODO: Replace this line to emit each character as single element
59-
Flux<String> flux = Flux.empty();
56+
Flux<String> flux = mono.map(s -> s.split("")).flatMapMany(Flux::fromArray);
6057

6158
StepVerifier.create(flux).expectNext("S", "c", "h", "r", "a", "d", "e", "r", "b", "r", "ä", "u").verifyComplete();
6259
}
@@ -67,8 +64,7 @@ public void fluxShouldConcatTwoMonos() {
6764
Mono<String> hello = Mono.just("Breaking");
6865
Mono<String> world = Mono.just("Bad");
6966

70-
// TODO: Replace this line to compose a stream from the two Monos
71-
Flux<String> flux = Flux.empty();
67+
Flux<String> flux = Flux.concat(hello, world);
7268

7369
StepVerifier.create(flux).expectNext("Breaking", "Bad").verifyComplete();
7470
}

0 commit comments

Comments
 (0)
0