BAEL-1080 Introduction to Future in Vavr (#3372)

* Add missing features

* Add missing features
This commit is contained in:
Ahmed Tawila 2018-01-09 13:31:45 +02:00 committed by Grzegorz Piwowarek
parent c8cf103fbc
commit 2b5a125440
1 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,14 @@ public class FutureTest {
assertThat(result)
.isEqualTo(HELLO);
}
@Test
public void whenTransform_thenCorrect() {
Future<Object> future = Future.of(() -> 5)
.transformValue(result -> Try.of(() -> HELLO + result.get()));
assertThat(future.get()).isEqualTo(HELLO + 5);
}
@Test
public void whenChainingCallbacks_thenCorrect() {
@ -139,6 +147,14 @@ public class FutureTest {
assertThat(futureResult.get())
.isEqualTo("Hello from Baeldung");
}
@Test
public void whenCallFlatMap_thenCorrect() {
Future<Object> futureMap = Future.of(() -> 1)
.flatMap((i) -> Future.of(() -> "Hello: " + i));
assertThat(futureMap.get()).isEqualTo("Hello: 1");
}
@Test
public void whenFutureFails_thenGetErrorMessage() {