BAEL-1080 Introduction to Future in Vavr (#3372)
* Add missing features * Add missing features
This commit is contained in:
parent
c8cf103fbc
commit
2b5a125440
|
@ -59,6 +59,14 @@ public class FutureTest {
|
|||
.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() {
|
||||
Future.of(() -> HELLO)
|
||||
|
@ -140,6 +148,14 @@ public class FutureTest {
|
|||
.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() {
|
||||
Future<String> future = Future.of(() -> "Hello".substring(-1))
|
||||
|
|
Loading…
Reference in New Issue