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();
}
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);
}
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);
}
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));
}
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)));
}
Aggregations