Skip to content

Commit

Permalink
fix #75 Add Flux.collect exercise (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
paweusz committed Sep 21, 2020
1 parent 356d928 commit 7525e5a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/io/pivotal/literx/Part08OtherOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

/**
* Learn how to use various other operators.
*
Expand Down Expand Up @@ -53,4 +55,11 @@ Mono<User> emptyToSkyler(Mono<User> mono) {
return null;
}

//========================================================================================

// TODO Convert the input Flux<User> to a Mono<List<User>> containing list of collected flux values
Mono<List<User>> fluxCollection(Flux<User> flux) {
return null;
}

}
14 changes: 14 additions & 0 deletions src/test/java/io/pivotal/literx/Part08OtherOperationsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import reactor.test.StepVerifier;
import reactor.test.publisher.PublisherProbe;

import java.util.Arrays;
import java.util.List;

/**
* Learn how to use various other operators.
*
Expand Down Expand Up @@ -111,4 +114,15 @@ public void emptyHandling() {
.verifyComplete();
}

//========================================================================================

@Test
public void collect() {
ReactiveRepository<User> repository = new ReactiveUserRepository();
Mono<List<User>> collection = workshop.fluxCollection(repository.findAll());
StepVerifier.create(collection)
.expectNext(Arrays.asList(User.SKYLER, User.JESSE, User.WALTER, User.SAUL))
.verifyComplete();
}

}

0 comments on commit 7525e5a

Please sign in to comment.