Reactor BubblingException in place of Custom Excep

2019-08-24 10:56发布

I am throwing an custom exception from the subscribe consumer but in the test case I am getting reactor.core.Exceptions.BubblingException.

part of code:

 return loginBOMonoValidated.map(this::checkAuth).map(login -> getUserContactsBOMono(login));

private LoginBO checkAuth(LoginBO loginBO) {

    if (!loginBO.getClientId().equals(loginBO.getLoginId())) {

      LoginDTO loginDTO = new LoginDTO(loginBO.getLoginId(), loginBO.getClientId());
      authorizationRemoteClient
          .validateManagerClientAccess(Mono.just(loginDTO))
          .subscribe(authClientConsumer);
      return new LoginBO(loginBO.getClientId(), loginBO.getClientId());
    } 
      else return loginBO;
  }

private Consumer<Boolean> authClientConsumer =
  bol -> {
    if (!bol) {
      logger.error(ErrorCodes.LOGIN_ID_VALIDATION_ERROR.getDescription());

      throw new AuthorizationException();
    }
  };

Test

Throwable exception =
        assertThrows(
            AuthorizationException.class,
            () -> {
              Mono<UserContactsBO> contact =contactInfoService.getUserContacts(Mono.just(new LoginBO("123456789", "1234")));
              contact.subscribe();
            });

Expected :..**.AuthorizationException

Actual:reactor.core.Exceptions.BubblingException

0条回答
登录 后发表回答