Search in sources :

Example 6 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentDownloadExtractServiceImplTest method getDocumentsSelectedBySeller_shouldSendMailNotificationWhenMiraklExceptionIsThrown.

@Test
void getDocumentsSelectedBySeller_shouldSendMailNotificationWhenMiraklExceptionIsThrown() {
    // formatter:off
    final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel = KYCDocumentSellerInfoModel.builder().clientUserId(MIRAKL_SHOP_ID).proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).proofOfAddress(KYCProofOfAddressEnum.BANK_STATEMENT).build();
    // formatter:on
    final MiraklException miraklException = new MiraklException("Something wrong happened");
    doThrow(miraklException).when(miraklMarketplacePlatformOperatorApiClientMock).getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)));
    testObj.getDocumentsSelectedBySeller(kycDocumentSellerInfoModel);
    verify(kycMailNotificationUtilMock).sendPlainTextEmail("Issue detected getting documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycDocumentSellerInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(miraklException)));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) Test(org.junit.jupiter.api.Test)

Example 7 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class AbstractUserDocumentFlagsStrategyTest method fillMiraklProofIdentityOrBusinessFlagStatus_shouldSendAnEmailWhenMiraklConnectionFails.

@Test
void fillMiraklProofIdentityOrBusinessFlagStatus_shouldSendAnEmailWhenMiraklConnectionFails() {
    // @formatter:off
    final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.INDIVIDUAL).verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED).build();
    // @formatter:on
    final MiraklException miraklException = new MiraklException("Something bad happened");
    doThrow(miraklException).when(miraklMarketplacePlatformOperatorApiClientMock).updateShops(any(MiraklUpdateShopsRequest.class));
    final Throwable throwable = catchThrowable(() -> testObj.fillMiraklProofIdentityOrBusinessFlagStatus(kycUserDocumentFlagsNotificationBodyModel));
    assertThat(throwable).isEqualTo(miraklException);
    assertThat(LOG_TRACKER_STUB.contains(String.format(MSG_ERROR, SHOP_ID, miraklException.getMessage()))).isTrue();
    verify(mailNotificationMock).sendPlainTextEmail("Issue detected updating KYC information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC information of shop [%s]%n%s", SHOP_ID, MiraklLoggingErrorsUtil.stringify(miraklException)));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) Test(org.junit.jupiter.api.Test)

Example 8 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method updateMiraklProofIdentityFlagStatus_whenAPICallThrowsException_shouldThrowException.

@Test
void updateMiraklProofIdentityFlagStatus_whenAPICallThrowsException_shouldThrowException() {
    final MiraklException exception = new MiraklException("An error has occurred");
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(miraklUpdateShopsRequestArgumentCaptor.capture())).thenThrow(exception);
    final Throwable throwable = catchThrowable(() -> testObj.updateMiraklProofIdentityFlagStatus(MIRAKL_SHOP_ID, BSTK_PROOF_IDENTITY_FIELD, HyperwalletUser.VerificationStatus.REQUIRED));
    assertThat(throwable).isEqualTo(exception);
    final MiraklUpdateShopsRequest result = miraklUpdateShopsRequestArgumentCaptor.getValue();
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValuesToBeChanged = result.getShops().get(0).getAdditionalFieldValues();
    assertThat(additionalFieldValuesToBeChanged).hasSize(1);
    final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue miraklSimpleRequestAdditionalFieldValue = (MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValuesToBeChanged.get(0);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getCode()).isEqualTo(BSTK_PROOF_IDENTITY_FIELD);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getValue()).isEqualTo("true");
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 9 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImplTest method getBusinessStakeholderDocumentsSelectedBySeller_shouldSendMailNotificationWhenMiraklExceptionIsThrown.

@Test
void getBusinessStakeholderDocumentsSelectedBySeller_shouldSendMailNotificationWhenMiraklExceptionIsThrown() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = KYCDocumentBusinessStakeHolderInfoModel.builder().businessStakeholderMiraklNumber(1).clientUserId(MIRAKL_SHOP_ID).proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).build();
    // @formatter:on
    final MiraklShopDocument miraklShopProofOfIdentityDocumentFront = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentFront.setTypeCode("hw-bsh1-proof-identity-front");
    final MiraklShopDocument miraklShopProofOfIdentityDocumentBack = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentBack.setTypeCode("hw-bsh1-proof-identity-back");
    final MiraklException miraklException = new MiraklException("Something wrong happened");
    doThrow(miraklException).when(miraklMarketplacePlatformOperatorApiClientMock).getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)));
    testObj.getBusinessStakeholderDocumentsSelectedBySeller(kycDocumentBusinessStakeHolderInfoModel);
    verify(kycMailNotificationUtilMock).sendPlainTextEmail("Issue detected getting business stakeholder documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycDocumentBusinessStakeHolderInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(miraklException)));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentsExtractServiceImplTest method setFlagToPushSellerDocumentsToFalse_shouldSendEmailNotificationWhenMiraklExceptionIsThrown.

@Test
void setFlagToPushSellerDocumentsToFalse_shouldSendEmailNotificationWhenMiraklExceptionIsThrown() {
    final KYCDocumentSellerInfoModel kycDocumentOne = KYCDocumentSellerInfoModel.builder().clientUserId("2000").build();
    final List<KYCDocumentSellerInfoModel> successfullyPushedDocumentsList = List.of(kycDocumentOne);
    final MiraklException miraklException = new MiraklException("Something went wrong");
    doThrow(miraklException).when(miraklMarketplacePlatformOperatorApiClientMock).updateShops(any(MiraklUpdateShopsRequest.class));
    testObj.setFlagToPushProofOfIdentityAndBusinessSellerDocumentsToFalse(successfullyPushedDocumentsList);
    verify(kycMailNotificationUtilMock).sendPlainTextEmail("Issue setting push document flags to false in Mirakl", String.format("Something went wrong setting push document flag to false in Mirakl for shop Id [2000]%n%s", String.join(",", MiraklLoggingErrorsUtil.stringify(miraklException))));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) Test(org.junit.jupiter.api.Test)

Aggregations

MiraklException (com.mirakl.client.core.exception.MiraklException)18 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)9 Test (org.junit.jupiter.api.Test)8 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)4 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)4 MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)4 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)3 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)3 KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)2 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)2 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)2 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)2 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)2 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)2 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 CollectionUtils (org.apache.commons.collections4.CollectionUtils)2