Search in sources :

Example 1 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest 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 2 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentDownloadExtractServiceImplTest method getDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies.

@Test
void getDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies() {
    final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel = KYCDocumentSellerInfoModel.builder().clientUserId(MIRAKL_SHOP_ID).proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).proofOfAddress(KYCProofOfAddressEnum.BANK_STATEMENT).build();
    final KYCDocumentModel kycDocumentModelFront = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_FRONT).build();
    final KYCDocumentModel kycDocumentModelBack = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_BACK).build();
    final MiraklShopDocument miraklShopProofOfIdentityDocumentFront = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentFront.setTypeCode("hw-ind-proof-identity-front");
    final MiraklShopDocument miraklShopProofOfIdentityDocumentBack = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentBack.setTypeCode("hw-ind-proof-identity-back");
    final MiraklShopDocument miraklShopProofOfAddressFront = new MiraklShopDocument();
    miraklShopProofOfAddressFront.setTypeCode("hw-ind-proof-address");
    final List<MiraklShopDocument> miraklShopDocumentsList = List.of(miraklShopProofOfIdentityDocumentFront, miraklShopProofOfIdentityDocumentBack, miraklShopProofOfAddressFront);
    when(miraklMarketplacePlatformOperatorApiClientMock.getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)))).thenReturn(miraklShopDocumentsList);
    final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelWithMiraklDocumentsShopInformation = kycDocumentSellerInfoModel.toBuilder().miraklShopDocuments(miraklShopDocumentsList).build();
    when(proofOfIdentityStrategyExecutorMock.execute(kycDocumentSellerInfoModelWithMiraklDocumentsShopInformation)).thenReturn(List.of(List.of(kycDocumentModelFront, kycDocumentModelBack)));
    final KYCDocumentSellerInfoModel result = testObj.getDocumentsSelectedBySeller(kycDocumentSellerInfoModel);
    verify(miraklMarketplacePlatformOperatorApiClientMock).getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)));
    verifyNoMoreInteractions(miraklMarketplacePlatformOperatorApiClientMock);
    assertThat(result.getDocuments()).containsExactlyInAnyOrder(kycDocumentModelFront, kycDocumentModelBack);
}
Also used : MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) Test(org.junit.jupiter.api.Test)

Example 3 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest 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 4 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImplTest method getBusinessStakeholderDocumentsSelectedBySeller_shouldNotPopulateKYCInfoModelWithDocumentInformationWhenLetterOfAuthorizationIsRequiredAndLetterOfAuthorizationDocumentIsNotFilled.

@Test
void getBusinessStakeholderDocumentsSelectedBySeller_shouldNotPopulateKYCInfoModelWithDocumentInformationWhenLetterOfAuthorizationIsRequiredAndLetterOfAuthorizationDocumentIsNotFilled() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = KYCDocumentBusinessStakeHolderInfoModel.builder().businessStakeholderMiraklNumber(1).requiresLetterOfAuthorization(Boolean.TRUE).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 List<MiraklShopDocument> miraklShopDocumentsList = List.of(miraklShopProofOfIdentityDocumentFront, miraklShopProofOfIdentityDocumentBack);
    when(miraklMarketplacePlatformOperatorApiClientMock.getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)))).thenReturn(miraklShopDocumentsList);
    final KYCDocumentBusinessStakeHolderInfoModel result = testObj.getBusinessStakeholderDocumentsSelectedBySeller(kycDocumentBusinessStakeHolderInfoModel);
    verify(miraklMarketplacePlatformOperatorApiClientMock).getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)));
    verifyNoMoreInteractions(miraklMarketplacePlatformOperatorApiClientMock);
    assertThat(result.getDocuments()).isEmpty();
}
Also used : 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 5 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImplTest method getBusinessStakeholderDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies.

@Test
void getBusinessStakeholderDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = KYCDocumentBusinessStakeHolderInfoModel.builder().businessStakeholderMiraklNumber(1).clientUserId(MIRAKL_SHOP_ID).proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).build();
    // @formatter:on
    final KYCDocumentModel kycDocumentModelFront = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_FRONT).build();
    final KYCDocumentModel kycDocumentModelBack = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_BACK).build();
    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 List<MiraklShopDocument> miraklShopDocumentsList = List.of(miraklShopProofOfIdentityDocumentFront, miraklShopProofOfIdentityDocumentBack);
    when(miraklMarketplacePlatformOperatorApiClientMock.getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)))).thenReturn(miraklShopDocumentsList);
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeholderInfoModelWithMiraklDocumentsShopInformation = kycDocumentBusinessStakeHolderInfoModel.toBuilder().miraklShopDocuments(miraklShopDocumentsList).build();
    when(proofOfIdentityStrategyExecutorMock.execute(kycDocumentBusinessStakeholderInfoModelWithMiraklDocumentsShopInformation)).thenReturn(List.of(List.of(kycDocumentModelFront, kycDocumentModelBack)));
    final KYCDocumentBusinessStakeHolderInfoModel result = testObj.getBusinessStakeholderDocumentsSelectedBySeller(kycDocumentBusinessStakeHolderInfoModel);
    verify(miraklMarketplacePlatformOperatorApiClientMock).getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)));
    verifyNoMoreInteractions(miraklMarketplacePlatformOperatorApiClientMock);
    assertThat(result.getDocuments()).containsExactlyInAnyOrder(kycDocumentModelFront, kycDocumentModelBack);
}
Also used : KYCDocumentModel(com.paypal.kyc.model.KYCDocumentModel) 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)

Aggregations

MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)8 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)7 Test (org.junit.jupiter.api.Test)6 MiraklException (com.mirakl.client.core.exception.MiraklException)4 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)2