BAEL-1080 Introduction to Future in Vavr (#3372)
* Add missing features * Add missing features
This commit is contained in:
parent
c8cf103fbc
commit
2b5a125440
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue