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