MailboxReactorUtils { public static <T> T block(Mono<T> publisher) throws MailboxException { try { return publisher.block(); } catch (RuntimeException e) { if (e.getCause() instanceof MailboxException) { throw (MailboxException) e.getCause(); } throw e; } }  static T block(Mono<T> publisher); static T block(Publisher<T> publisher); static Optional<T> blockOptional(Mono<T> publisher);  }
@Test void blockJustShouldReturnTheValue() throws Exception { assertThat(MailboxReactorUtils.block(Mono.just(42))) .isEqualTo(42); }
@Test void blockEmptyShouldReturnNull() throws Exception { assertThat((Integer) MailboxReactorUtils.block(Mono.empty())) .isNull(); }
@Test void blockErrorMailboxExceptionShouldThrowMailboxException() { assertThatThrownBy(() -> MailboxReactorUtils.block(Mono.error(new MailboxException()))) .isInstanceOf(MailboxException.class); }
@Test void blockErrorRuntimeExceptionShouldThrowRuntimeException() { assertThatThrownBy(() -> MailboxReactorUtils.block(Mono.error(new RuntimeException()))) .isInstanceOf(RuntimeException.class); }