Search in sources :

Example 6 with HyperwalletBankAccount

use of com.hyperwallet.clientsdk.model.HyperwalletBankAccount in project mirakl-hyperwallet-connector by paypal.

the class SellerModelToHyperWalletCanadianBankAccountTest method execute_shouldReturnCanadianHyperwalletBankAccount.

@Test
void execute_shouldReturnCanadianHyperwalletBankAccount() {
    final HyperwalletBankAccount hyperwalletBankAccount = new HyperwalletBankAccount();
    when(sellerModelMock.getBankAccountDetails()).thenReturn(canadianBankAccountModelMock);
    when(canadianBankAccountModelMock.getBankId()).thenReturn(BANK_ID);
    when(canadianBankAccountModelMock.getBranchId()).thenReturn(BRANCH_ID);
    doReturn(hyperwalletBankAccount).when(testObj).callSuperConvert(sellerModelMock);
    final HyperwalletBankAccount result = testObj.execute(sellerModelMock);
    assertThat(result.getBranchId()).isEqualTo(BRANCH_ID);
    assertThat(result.getBankId()).isEqualTo(BANK_ID);
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Example 7 with HyperwalletBankAccount

use of com.hyperwallet.clientsdk.model.HyperwalletBankAccount in project mirakl-hyperwallet-connector by paypal.

the class SellerModelToHyperWalletIBANBankAccountConverterTest method convert_shouldReturnIBANHyperwalletBankAccount.

@Test
void convert_shouldReturnIBANHyperwalletBankAccount() {
    final HyperwalletBankAccount hyperwalletBankAccount = new HyperwalletBankAccount();
    when(sellerModelMock.getBankAccountDetails()).thenReturn(ibanBankAccountModelMock);
    when(ibanBankAccountModelMock.getBankBic()).thenReturn(BANK_BIC);
    doReturn(hyperwalletBankAccount).when(testObj).callSuperConvert(sellerModelMock);
    final HyperwalletBankAccount result = testObj.execute(sellerModelMock);
    assertThat(result.getBankId()).isEqualTo(BANK_BIC);
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Example 8 with HyperwalletBankAccount

use of com.hyperwallet.clientsdk.model.HyperwalletBankAccount in project mirakl-hyperwallet-connector by paypal.

the class SellerModelToHyperWalletUKBankAccountTest method convert_shouldReturnUKHyperwalletBankAccount.

@Test
void convert_shouldReturnUKHyperwalletBankAccount() {
    final HyperwalletBankAccount hyperwalletBankAccount = new HyperwalletBankAccount();
    when(sellerModelMock.getBankAccountDetails()).thenReturn(ukBankAccountModelMock);
    when(ukBankAccountModelMock.getBankAccountId()).thenReturn(SORT_CODE);
    doReturn(hyperwalletBankAccount).when(testObj).callSuperConvert(sellerModelMock);
    final HyperwalletBankAccount result = testObj.execute(sellerModelMock);
    assertThat(result.getBankId()).isEqualTo(SORT_CODE);
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Example 9 with HyperwalletBankAccount

use of com.hyperwallet.clientsdk.model.HyperwalletBankAccount in project mirakl-hyperwallet-connector by paypal.

the class HyperWalletCreateBankAccountServiceStrategyTest method callHyperwalletAPI_shouldCreateBankAccount.

@Test
void callHyperwalletAPI_shouldCreateBankAccount() {
    when(hyperwalletMock.createBankAccount(hyperwalletBankAccountRequestMock)).thenReturn(hyperwalletBankAccountResultMock);
    when(hyperwalletSDKServiceMock.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletMock);
    final HyperwalletBankAccount result = testObj.callHyperwalletAPI(HYPERWALLET_PROGRAM, hyperwalletBankAccountRequestMock);
    verify(hyperwalletSDKServiceMock).getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM);
    verify(hyperwalletMock).createBankAccount(hyperwalletBankAccountRequestMock);
    assertThat(result).isEqualTo(hyperwalletBankAccountResultMock);
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Example 10 with HyperwalletBankAccount

use of com.hyperwallet.clientsdk.model.HyperwalletBankAccount in project mirakl-hyperwallet-connector by paypal.

the class AbstractHyperwalletBankAccountRetryApiStrategy method execute.

/**
 * {@inheritDoc}
 */
@Override
public Optional<HyperwalletBankAccount> execute(final SellerModel seller) {
    boolean includedAsFailed = false;
    HyperwalletBankAccount hwCreatedBankAccount = null;
    final HyperwalletBankAccount hwBankAccountRequest = sellerModelToHyperwalletBankAccountStrategyExecutor.execute(seller);
    if (Objects.nonNull(hwBankAccountRequest)) {
        try {
            hwCreatedBankAccount = callHyperwalletAPI(seller.getHyperwalletProgram(), hwBankAccountRequest);
            log.info("Bank account created or updated for seller with clientId [{}]", seller.getClientUserId());
        } catch (final HyperwalletException e) {
            if (e.getCause() instanceof IOException) {
                includedAsFailed = true;
            }
            mailNotificationUtil.sendPlainTextEmail("Issue detected when creating or updating bank account in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Bank account not created or updated for seller with clientId [%s]%n%s", seller.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
            log.error("Bank account not created or updated for seller with clientId [{}]", seller.getClientUserId());
            log.error(HyperwalletLoggingErrorsUtil.stringify(e));
        } finally {
            callToIncludeIntoRetryProcess(seller, includedAsFailed);
        }
    }
    return Optional.ofNullable(hwCreatedBankAccount);
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) IOException(java.io.IOException)

Aggregations

HyperwalletBankAccount (com.hyperwallet.clientsdk.model.HyperwalletBankAccount)12 Test (org.junit.jupiter.api.Test)10 AbstractSellerModelToHyperwalletBankAccount (com.paypal.sellers.bankaccountextract.converter.impl.sellermodel.AbstractSellerModelToHyperwalletBankAccount)4 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)1 BankAccountModel (com.paypal.sellers.bankaccountextract.model.BankAccountModel)1 IBANBankAccountModel (com.paypal.sellers.bankaccountextract.model.IBANBankAccountModel)1 IOException (java.io.IOException)1