Check failure propagation in UniOnNullSwitch
@@ -23,6 +23,13 @@ public class UniOnNullSwitchToTest {
.await().indefinitely()).isEqualTo(23);
}
+ @Test
+ public void testSwitchOnNonNull() {
+ assertThat(Uni.createFrom().item(1).onItem().castTo(Integer.class)
+ .onItem().ifNull().switchTo(fallback)
+ .await().indefinitely()).isEqualTo(1);
+ }
+
@Test
public void testSwitchToSupplierFallback() {
AtomicInteger count = new AtomicInteger();
@@ -52,9 +59,21 @@ public class UniOnNullSwitchToTest {
.onItem().ifNull().switchTo(() -> failure)
.await().indefinitely())
.withMessageEndingWith("boom");
+ }
+
+ @Test
+ public void testSwitchToSupplierThrowingException() {
+ assertThatExceptionOfType(IllegalStateException.class)
+ .isThrownBy(() -> Uni.createFrom().item((Object) null).onItem().castTo(Integer.class)
+ .onItem().ifNull().switchTo(() -> {
+ throw new IllegalStateException("boom");
+ })
+ .await().indefinitely())
+ .withMessageEndingWith("boom");
}
+
@Test
public void testSwitchToNull() {
assertThrows(NullPointerException.class, () -> Uni.createFrom().item((Object) null).onItem().castTo(Integer.class)
