Search in sources :

Example 16 with KYCDocumentBusinessStakeHolderInfoModel

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

the class MiraklProofOfBusinessStrategyTest method isApplicable_shouldReturnFalseWhenIsProofOfBusinessAndObjectReceivedAsParameterIsNotKYCDocumentSellerInfoModel.

@Test
void isApplicable_shouldReturnFalseWhenIsProofOfBusinessAndObjectReceivedAsParameterIsNotKYCDocumentSellerInfoModel() {
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = KYCDocumentBusinessStakeHolderInfoModel.builder().build();
    final boolean result = testObj.isApplicable(kycDocumentBusinessStakeHolderInfoModel);
    assertThat(result).isFalse();
}
Also used : KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with KYCDocumentBusinessStakeHolderInfoModel

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

the class HyperwalletBusinessStakeholderExtractServiceImplTest method pushBusinessStakeholderDocuments_shouldSkipBusinessStakeholdersWithNotAllDocumentsFulfilled.

@Test
void pushBusinessStakeholderDocuments_shouldSkipBusinessStakeholdersWithNotAllDocumentsFulfilled() {
    // @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 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).build());
    // @formatter:on
    when(userOneBstkOne.areDocumentsFilled()).thenReturn(true);
    when(userOneBstkThree.areDocumentsFilled()).thenReturn(true);
    when(userTwoBstkThree.areDocumentsFilled()).thenReturn(false);
    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);
    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);
    assertThat(result).containsExactlyInAnyOrder(userOneBstkOneSentToHW, userOneBstkThreeSentToHW);
}
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 18 with KYCDocumentBusinessStakeHolderInfoModel

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

the class HyperwalletBusinessStakeholderExtractServiceImplTest method pushBusinessStakeholderDocuments_whenHyperwalletAPIFailsWithOneSpecificBstkFile_shouldFailGracefully.

@Test
void pushBusinessStakeholderDocuments_whenHyperwalletAPIFailsWithOneSpecificBstkFile_shouldFailGracefully() {
    // @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
    // @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());
    final KYCDocumentBusinessStakeHolderInfoModel userTwoBstkThreeSentToHW = userTwoBstkThree.toBuilder().sentToHyperwallet(Boolean.TRUE).build();
    // @formatter:on
    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 HyperwalletException expectedException = new HyperwalletException("Something went wrong");
    lenient().when(hyperwalletApiClientMock.uploadStakeholderDocuments("usr-1", "stk-3", usrOneBstThreeFilesDataList)).thenThrow(expectedException);
    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);
    verify(kycMailNotificationUtilMock).sendPlainTextEmail("Issue detected pushing documents into Hyperwallet", String.format("Something went wrong pushing documents to Hyperwallet for shop Id [2000] and business stakeholder number [3]%n%s", HyperwalletLoggingErrorsUtil.stringify(expectedException)));
    assertThat(result).containsExactlyInAnyOrder(userOneBstkOneSentToHW, userOneBstkThree, userTwoBstkThreeSentToHW);
}
Also used : HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) KYCDocumentModel(com.paypal.kyc.model.KYCDocumentModel) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Example 19 with KYCDocumentBusinessStakeHolderInfoModel

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

the class HyperwalletBusinessStakeholderExtractServiceMockImplTest method execute_shouldRunPushDocumentsToMockServer.

@Test
void execute_shouldRunPushDocumentsToMockServer() {
    // @formatter:off
    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();
    // @formatter:on
    HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
    hyperwalletVerificationDocument.setCategory("category");
    hyperwalletVerificationDocument.setCountry("ES");
    hyperwalletVerificationDocument.setType("type");
    hyperwalletVerificationDocument.setUploadFiles(Map.of("key1", "value1"));
    when(testObj.getMockServerUrl()).thenReturn(MOCK_SERVER_URL);
    final Map<KYCDocumentBusinessStakeHolderInfoModel, List<HyperwalletVerificationDocument>> kycDocumentOne1 = Map.of(kycDocumentOne, List.of(hyperwalletVerificationDocument));
    testObj.callHyperwalletAPI(kycDocumentOne1.entrySet().iterator().next());
    verify(restTemplateMock).postForObject(eq(MOCK_SERVER_URL + HYPERWALLET_PUSH_DOCUMENTS), Mockito.any(), eq(Object.class));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) List(java.util.List) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Example 20 with KYCDocumentBusinessStakeHolderInfoModel

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

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