Search in sources :

Example 11 with KYCDocumentBusinessStakeHolderInfoModel

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

the class KYCReadyForReviewServiceImplTest method notifyDocumentsSent_whenDocumentsWereSentToHyperwallet_shouldNotifyBstkReadyForReview.

@Test
void notifyDocumentsSent_whenDocumentsWereSentToHyperwallet_shouldNotifyBstkReadyForReview() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentSent = KYCDocumentBusinessStakeHolderInfoModel.builder().userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN_1))).hyperwalletProgram(HYPERWALLET_PROGRAM).sentToHyperwallet(Boolean.TRUE).build();
    // @formatter:on
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentNotSent = KYCDocumentBusinessStakeHolderInfoModel.builder().userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN_2))).hyperwalletProgram(HYPERWALLET_PROGRAM).sentToHyperwallet(Boolean.FALSE).build();
    // @formatter:on
    doNothing().when(testObj).notifyBstkReadyForReview(Map.entry(USER_TOKEN_1, List.of(kycDocumentSent)));
    testObj.notifyReadyForReview(List.of(kycDocumentSent, kycDocumentNotSent));
    verify(testObj).notifyBstkReadyForReview(Map.entry(USER_TOKEN_1, List.of(kycDocumentSent)));
    verify(testObj, never()).notifyBstkReadyForReview(Map.entry(USER_TOKEN_2, List.of(kycDocumentNotSent)));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Example 12 with KYCDocumentBusinessStakeHolderInfoModel

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

the class KYCReadyForReviewServiceMockImplTest method notifyBstkReadyForReview_shouldRunNotifyBusinessStakeholderToMockServer.

@Test
void notifyBstkReadyForReview_shouldRunNotifyBusinessStakeholderToMockServer() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId(SHOP_ID).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN))).build();
    // @formatter:on
    when(testObj.getMockServerUrl()).thenReturn(MOCK_SERVER_URL);
    testObj.notifyBstkReadyForReview(Map.entry(USER_TOKEN, List.of(kycDocumentOne)));
    verify(restTemplateMock).put(eq(MOCK_SERVER_URL + HYPERWALLET_NOTIFY_USER), any(), eq(Object.class));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Example 13 with KYCDocumentBusinessStakeHolderInfoModel

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

the class HyperwalletBusinessStakeholderExtractServiceImplTest method pushBusinessStakeholderDocuments_whenAllDocumentsAreFulfilledByBusinessStakeholder_shouldPushDocumentsForBusinessStakeholders.

@Test
void pushBusinessStakeholderDocuments_whenAllDocumentsAreFulfilledByBusinessStakeholder_shouldPushDocumentsForBusinessStakeholders() {
    // @formatter:off
    final KYCDocumentModel userOneBstkOneFrontDocument = KYCDocumentModel.builder().documentFieldName(PROOF_OF_IDENTITY_FRONT_BSH1).file(usrOneBstkOneFileFrontMock).build();
    // @formatter:on
    // @formatter:off
    final KYCDocumentModel userOneBstkOneBackDocument = KYCDocumentModel.builder().documentFieldName(PROOF_OF_IDENTITY_BACK_BSH1).file(usrOneBstkOneFileBackMock).build();
    // @formatter:on
    // @formatter:off
    final KYCDocumentModel userOneBstkThreeFrontDocument = KYCDocumentModel.builder().documentFieldName(PROOF_OF_IDENTITY_FRONT_BSH3).file(userOneBstkThreeFileFrontMock).build();
    // @formatter:on
    // @formatter:off
    final KYCDocumentModel userTwoBstkOneFrontDocument = KYCDocumentModel.builder().documentFieldName(PROOF_OF_IDENTITY_FRONT_BSH1).file(userTwoBstkThreeFileFrontMock).build();
    // @formatter:on
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel userOneBstkOne = Mockito.spy(KYCDocumentBusinessStakeHolderInfoModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).businessStakeholderMiraklNumber(1).token("stk-1").requiresKYC(true).userToken("usr-1").clientUserId("2000").proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).documents(List.of(userOneBstkOneFrontDocument, userOneBstkOneBackDocument)).build());
    // @formatter:on
    final KYCDocumentBusinessStakeHolderInfoModel userOneBstkOneSentToHW = userOneBstkOne.toBuilder().sentToHyperwallet(Boolean.TRUE).build();
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel userOneBstkThree = Mockito.spy(KYCDocumentBusinessStakeHolderInfoModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).businessStakeholderMiraklNumber(3).token("stk-3").requiresKYC(true).userToken("usr-1").clientUserId("2000").proofOfIdentity(KYCProofOfIdentityEnum.PASSPORT).documents(List.of(userOneBstkThreeFrontDocument)).build());
    // @formatter:on
    final KYCDocumentBusinessStakeHolderInfoModel userOneBstkThreeSentToHW = userOneBstkThree.toBuilder().sentToHyperwallet(Boolean.TRUE).build();
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel userTwoBstkThree = Mockito.spy(KYCDocumentBusinessStakeHolderInfoModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).businessStakeholderMiraklNumber(3).token("stk-3").requiresKYC(true).userToken("usr-2").clientUserId("2001").proofOfIdentity(KYCProofOfIdentityEnum.PASSPORT).documents(List.of(userTwoBstkOneFrontDocument)).build());
    // @formatter:on
    final KYCDocumentBusinessStakeHolderInfoModel userTwoBstkThreeSentToHW = userTwoBstkThree.toBuilder().sentToHyperwallet(Boolean.TRUE).build();
    when(userOneBstkOne.areDocumentsFilled()).thenReturn(true);
    when(userOneBstkThree.areDocumentsFilled()).thenReturn(true);
    when(userTwoBstkThree.areDocumentsFilled()).thenReturn(true);
    final List<HyperwalletVerificationDocument> usrOneBstOneFilesOneDataList = List.of(usrOneBstOneFilesOneDataMock);
    when(businessStakeholderDocumentInfoModelToHWVerificationDocumentMultipleStrategyExecutorMock.execute(userOneBstkOne)).thenReturn(usrOneBstOneFilesOneDataList);
    final List<HyperwalletVerificationDocument> usrOneBstThreeFilesDataList = List.of(usrOneBstThreeFilesDataMock);
    when(businessStakeholderDocumentInfoModelToHWVerificationDocumentMultipleStrategyExecutorMock.execute(userOneBstkThree)).thenReturn(usrOneBstThreeFilesDataList);
    final List<HyperwalletVerificationDocument> usrTwoBstOneFilesDataList = List.of(usrTwoBstThreeFilesDataMock);
    when(businessStakeholderDocumentInfoModelToHWVerificationDocumentMultipleStrategyExecutorMock.execute(userTwoBstkThree)).thenReturn(usrTwoBstOneFilesDataList);
    when(hyperwalletSDKServiceMock.getHyperwalletInstance(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletApiClientMock);
    final List<KYCDocumentBusinessStakeHolderInfoModel> result = testObj.pushBusinessStakeholderDocuments(List.of(userOneBstkOne, userOneBstkThree, userTwoBstkThree));
    verify(hyperwalletApiClientMock).uploadStakeholderDocuments("usr-1", "stk-1", usrOneBstOneFilesOneDataList);
    verify(hyperwalletApiClientMock).uploadStakeholderDocuments("usr-1", "stk-3", usrOneBstThreeFilesDataList);
    verify(hyperwalletApiClientMock).uploadStakeholderDocuments("usr-2", "stk-3", usrTwoBstOneFilesDataList);
    assertThat(result).containsExactlyInAnyOrder(userOneBstkOneSentToHW, userOneBstkThreeSentToHW, userTwoBstkThreeSentToHW);
}
Also used : HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) KYCDocumentModel(com.paypal.kyc.model.KYCDocumentModel) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Example 14 with KYCDocumentBusinessStakeHolderInfoModel

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

the class HyperwalletBusinessStakeholderExtractServiceMockImplTest method execute_shouldSendEmailNotificationWhenFailingFilesAreIncluded.

@Test
void execute_shouldSendEmailNotificationWhenFailingFilesAreIncluded() {
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId(SHOP_ID).token(BUSINESS_STAKEHOLDER_TOKEN).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN))).businessStakeholderMiraklNumber(BUSINESS_STAKEHOLDER_NUMBER).proofOfIdentity(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HW_STAKEHOLDER_PROOF_IDENTITY_TYPE_1, "GOVERNMENT_ID")), BUSINESS_STAKEHOLDER_NUMBER).build();
    HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
    hyperwalletVerificationDocument.setCategory("category");
    hyperwalletVerificationDocument.setCountry("ES");
    hyperwalletVerificationDocument.setType("type");
    hyperwalletVerificationDocument.setUploadFiles(Map.of("key1", "value1", "fail", "failFile"));
    final Map<KYCDocumentBusinessStakeHolderInfoModel, List<HyperwalletVerificationDocument>> kycDocumentOne1 = Map.of(kycDocumentOne, List.of(hyperwalletVerificationDocument));
    final Map.Entry<KYCDocumentBusinessStakeHolderInfoModel, List<HyperwalletVerificationDocument>> entry = kycDocumentOne1.entrySet().stream().findAny().get();
    testObj.callHyperwalletAPI(entry);
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected pushing documents into Hyperwallet", String.format("Something went wrong pushing documents to Hyperwallet for shop Id [%s] and business stakeholder number [%s]%n%s", SHOP_ID, BUSINESS_STAKEHOLDER_NUMBER, HyperwalletLoggingErrorsUtil.stringify(new HyperwalletException("Something bad happened"))));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) List(java.util.List) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 15 with KYCDocumentBusinessStakeHolderInfoModel

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

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImplTest method getBusinessStakeholderDocumentsSelectedBySeller_shouldReturnSameInputWhenRequiresLetterOfAuthorizationButDocumentsDoesNotExists.

@Test
void getBusinessStakeholderDocumentsSelectedBySeller_shouldReturnSameInputWhenRequiresLetterOfAuthorizationButDocumentsDoesNotExists() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = KYCDocumentBusinessStakeHolderInfoModel.builder().requiresLetterOfAuthorization(true).businessStakeholderMiraklNumber(1).clientUserId(MIRAKL_SHOP_ID).proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).build();
    // @formatter:on
    final KYCDocumentBusinessStakeHolderInfoModel result = testObj.getBusinessStakeholderDocumentsSelectedBySeller(kycDocumentBusinessStakeHolderInfoModel);
    assertThat(kycDocumentBusinessStakeHolderInfoModel).isEqualTo(result);
}
Also used : KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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