Search in sources :

Example 26 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImplTest method getBusinessStakeholderDocumentsSelectedBySeller_whenDocumentsAremissingForShop_shouldReturnShopDocument_andNeverSelectDocuments.

@MethodSource("documents")
@ParameterizedTest
void getBusinessStakeholderDocumentsSelectedBySeller_whenDocumentsAremissingForShop_shouldReturnShopDocument_andNeverSelectDocuments(final KYCDocumentBusinessStakeHolderInfoModel document) {
    doReturn(document).when(testObj).populateMiraklShopBusinessStakeholderDocuments(KYCDocumentBusinessStakeHolderInfoModelMock);
    final KYCDocumentBusinessStakeHolderInfoModel result = testObj.getBusinessStakeholderDocumentsSelectedBySeller(KYCDocumentBusinessStakeHolderInfoModelMock);
    assertThat(result).isEqualTo(document);
    verify(proofOfIdentityStrategyExecutorMock, never()).execute(any());
}
Also used : KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel 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)

Example 28 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImplTest method getBusinessStakeholderDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies_whenLetterOfAuthorizationIsRequiredAndLetterOfAuthorizationDocumentIsFilled.

@Test
void getBusinessStakeholderDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies_whenLetterOfAuthorizationIsRequiredAndLetterOfAuthorizationDocumentIsFilled() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = KYCDocumentBusinessStakeHolderInfoModel.builder().businessStakeholderMiraklNumber(1).requiresLetterOfAuthorization(Boolean.TRUE).clientUserId(MIRAKL_SHOP_ID).proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).build();
    // @formatter:on
    final KYCDocumentModel kycDocumentModelProofOfIdentityFront = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_FRONT).build();
    final KYCDocumentModel kycDocumentModelProofOfIdentityBack = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_BACK).build();
    final KYCDocumentModel kycDocumentModelLetterOfAuthorization = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_AUTHORIZATION).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 MiraklShopDocument miraklShopLetterOfAuthorizationDocument = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentBack.setTypeCode("hw-bsh-letter-authorization");
    final List<MiraklShopDocument> miraklShopDocumentsList = List.of(miraklShopProofOfIdentityDocumentFront, miraklShopProofOfIdentityDocumentBack, miraklShopLetterOfAuthorizationDocument);
    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(kycDocumentModelProofOfIdentityFront, kycDocumentModelProofOfIdentityBack, kycDocumentModelLetterOfAuthorization)));
    final KYCDocumentBusinessStakeHolderInfoModel result = testObj.getBusinessStakeholderDocumentsSelectedBySeller(kycDocumentBusinessStakeHolderInfoModel);
    verify(miraklMarketplacePlatformOperatorApiClientMock).getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)));
    verifyNoMoreInteractions(miraklMarketplacePlatformOperatorApiClientMock);
    assertThat(result.getDocuments()).containsExactlyInAnyOrder(kycDocumentModelProofOfIdentityFront, kycDocumentModelProofOfIdentityBack, kycDocumentModelLetterOfAuthorization);
}
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)

Example 29 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class KYCReadyForReviewServiceImplTest method notifyBstk_shouldShowLogSayingClientIdHasNoHyperwalletProgramAssigned.

@Test
void notifyBstk_shouldShowLogSayingClientIdHasNoHyperwalletProgramAssigned() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2000").userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN_1))).build();
    // @formatter:on
    testObj.notifyBstkReadyForReview(Map.entry(USER_TOKEN_1, List.of(kycDocumentOne)));
    assertThat(logTrackerStub.contains("Seller with shop Id [2000] has no Hyperwallet Program")).isTrue();
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Example 30 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class KYCReadyForReviewServiceImplTest method notifyBstkReadyForReview_shouldRunNotifyBusinessStakeholderToHW.

@Test
void notifyBstkReadyForReview_shouldRunNotifyBusinessStakeholderToHW() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentOne = KYCDocumentBusinessStakeHolderInfoModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN_1))).build();
    // @formatter:on
    when(hyperwalletApiClientMock.updateUser(Mockito.any(HyperwalletUser.class))).thenReturn(hyperwalletUserMock);
    when(hyperwalletUserMock.getClientUserId()).thenReturn(SHOP_ID);
    when(hyperwalletSDKServiceMock.getHyperwalletInstance(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletApiClientMock);
    testObj.notifyBstkReadyForReview(Map.entry(USER_TOKEN_1, List.of(kycDocumentOne)));
    verify(hyperwalletApiClientMock).updateUser(hyperwalletUserCaptor.capture());
    final HyperwalletUser hyperwalletUser = hyperwalletUserCaptor.getValue();
    assertThat(hyperwalletUser.getToken()).isEqualTo(USER_TOKEN_1);
    assertThat(hyperwalletUser.getBusinessStakeholderVerificationStatus()).isEqualTo(HyperwalletUser.BusinessStakeholderVerificationStatus.READY_FOR_REVIEW);
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Aggregations

KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)36 Test (org.junit.jupiter.api.Test)27 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 HyperwalletVerificationDocument (com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)8 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)7 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)6 MiraklException (com.mirakl.client.core.exception.MiraklException)4 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)4 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)4 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)4 MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)4 Collectors (java.util.stream.Collectors)4 Service (org.springframework.stereotype.Service)4 ObjectUtils (org.springframework.util.ObjectUtils)4 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)3 Map (java.util.Map)3 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)2 AbstractMiraklShop (com.mirakl.client.mmp.domain.shop.AbstractMiraklShop)2 MiraklShops (com.mirakl.client.mmp.domain.shop.MiraklShops)2