Search in sources :

Example 6 with HyperwalletException

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

the class AbstractHyperwalletSellerRetryApiStrategyTest method execute_shouldSendEmailNotificationHyperwalletExceptionIsThrown.

@Test
void execute_shouldSendEmailNotificationHyperwalletExceptionIsThrown() {
    final HyperwalletException hyperwalletException = new HyperwalletException("Something went wrong");
    when(sellerModelMock.getClientUserId()).thenReturn("2001");
    when(sellerModelHyperwalletUserConverterMock.convert(sellerModelMock)).thenReturn(hyperwalletUserMock);
    doNothing().when(testObj).callToIncludeIntoRetryProcess(sellerModelMock, Boolean.FALSE);
    doThrow(hyperwalletException).when(testObj).createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(hyperwalletUserMock);
    testObj.execute(sellerModelMock);
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected when creating or updating seller in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Seller not created or updated with clientId [%s]%n%s", "2001", HyperwalletLoggingErrorsUtil.stringify(hyperwalletException)));
    verify(testObj).callToIncludeIntoRetryProcess(sellerModelMock, Boolean.FALSE);
}
Also used : HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) Test(org.junit.jupiter.api.Test)

Example 7 with HyperwalletException

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

the class HyperWalletCreateBusinessStakeHolderServiceStrategyTest method execute_shouldSendEmailNotificationHyperwalletExceptionIsThrown.

@Test
void execute_shouldSendEmailNotificationHyperwalletExceptionIsThrown() {
    when(businessStakeHolderModelHyperwalletBusinessStakeholderConverterMock.convert(businessStakeHolderMock)).thenReturn(hyperwalletBusinessStakeholderMock);
    when(businessStakeHolderMock.getClientUserId()).thenReturn(CLIENT_ID);
    when(businessStakeHolderMock.getUserToken()).thenReturn(TOKEN);
    when(businessStakeHolderMock.getHyperwalletProgram()).thenReturn(HYPERWALLET_PROGRAM);
    when(hyperwalletSDKServiceMock.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletClientMock);
    final HyperwalletException hyperwalletException = new HyperwalletException("Something went wrong");
    doThrow(hyperwalletException).when(hyperwalletClientMock).createBusinessStakeholder(TOKEN, hyperwalletBusinessStakeholderMock);
    testObj.execute(businessStakeHolderMock);
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected when creating business stakeholder in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Business stakeholder not created for clientId [%s]%n%s", CLIENT_ID, HyperwalletLoggingErrorsUtil.stringify(hyperwalletException)));
}
Also used : HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) Test(org.junit.jupiter.api.Test)

Example 8 with HyperwalletException

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

the class HyperWalletUpdateBusinessStakeHolderServiceStrategyTest method execute_shouldSendEmailNotificationHyperwalletExceptionIsThrown.

@Test
void execute_shouldSendEmailNotificationHyperwalletExceptionIsThrown() {
    when(businessStakeHolderModelHyperwalletBusinessStakeholderConverterMock.convert(businessStakeHolderMock)).thenReturn(hyperwalletBusinessStakeholderMock);
    when(businessStakeHolderMock.getUserToken()).thenReturn(TOKEN);
    when(businessStakeHolderMock.getClientUserId()).thenReturn(CLIENT_ID);
    when(businessStakeHolderMock.getHyperwalletProgram()).thenReturn(HYPERWALLET_PROGRAM);
    when(hyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletClientMock);
    final HyperwalletException hyperwalletException = new HyperwalletException("Something went wrong");
    doThrow(hyperwalletException).when(hyperwalletClientMock).updateBusinessStakeholder(TOKEN, hyperwalletBusinessStakeholderMock);
    testObj.execute(businessStakeHolderMock);
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected when updating business stakeholder in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Business stakeholder not updated for clientId [%s]%n%s", CLIENT_ID, HyperwalletLoggingErrorsUtil.stringify(hyperwalletException)));
}
Also used : HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) Test(org.junit.jupiter.api.Test)

Example 9 with HyperwalletException

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

the class HyperWalletPaymentExtractServiceImplTest method createPayment_shouldSendAnEmailWhenAnExceptionIsThrown.

@Test
void createPayment_shouldSendAnEmailWhenAnExceptionIsThrown() {
    final HyperwalletException hyperwalletException = new HyperwalletException("Something went wrong");
    doThrow(hyperwalletException).when(hyperwalletMock).createPayment(paymentOneMock);
    when(paymentOneMock.getClientPaymentId()).thenReturn("000001234");
    when(paymentOneMock.getProgramToken()).thenReturn(PROGRAM_TOKEN);
    when(hyperwalletSDKService.getHyperwalletInstanceWithProgramToken(PROGRAM_TOKEN)).thenReturn(hyperwalletMock);
    testObj.createPayment(paymentOneMock);
    verify(mailNotificationUtil).sendPlainTextEmail("Issue detected when creating payment for an invoice in Hyperwallet", String.format("Something went wrong creating payment " + "for" + " invoice [000001234]%n%s", HyperwalletLoggingErrorsUtil.stringify(hyperwalletException)));
}
Also used : HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) Test(org.junit.jupiter.api.Test)

Example 10 with HyperwalletException

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

the class AbstractHyperwalletSellerRetryApiStrategy method execute.

/**
 * {@inheritDoc}
 */
@Override
public HyperwalletUser execute(final SellerModel seller) {
    boolean includedAsFailed = false;
    HyperwalletUser hyperwalletUser = null;
    final HyperwalletUser hwUserRequest = sellerModelHyperwalletUserConverter.convert(seller);
    try {
        hyperwalletUser = createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(hwUserRequest);
        log.info("Seller 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 seller in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Seller not created or updated with clientId [%s]%n%s", seller.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
        log.error("Seller not created or updated with clientId [{}]", seller.getClientUserId());
        log.error(HyperwalletLoggingErrorsUtil.stringify(e));
    } finally {
        callToIncludeIntoRetryProcess(seller, includedAsFailed);
    }
    return hyperwalletUser;
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) IOException(java.io.IOException)

Aggregations

HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)36 Test (org.junit.jupiter.api.Test)15 Hyperwallet (com.hyperwallet.clientsdk.Hyperwallet)7 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)6 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)6 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)5 HyperwalletVerificationDocument (com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)5 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)5 IOException (java.io.IOException)5 Response (cc.protea.util.http.Response)4 Test (org.testng.annotations.Test)4 Gson (com.google.gson.Gson)3 HyperwalletPayment (com.hyperwallet.clientsdk.model.HyperwalletPayment)3 JOSEException (com.nimbusds.jose.JOSEException)3 File (java.io.File)3 ParseException (java.text.ParseException)3 HyperwalletBusinessStakeholder (com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder)2 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)2 List (java.util.List)2 Map (java.util.Map)2