use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class DocumentsExtractServiceImplTest method cleanUpFiles_shouldRemoveFilesReceivedAsParameter.
@Test
void cleanUpFiles_shouldRemoveFilesReceivedAsParameter() {
final KYCDocumentModel kycDocumentModelOne = KYCDocumentModel.builder().file(fileOneMock).build();
final KYCDocumentModel kycDocumentModelTwo = KYCDocumentModel.builder().file(fileTwoMock).build();
final KYCDocumentSellerInfoModel kycDocumentOne = KYCDocumentSellerInfoModel.builder().clientUserId("2000").documents(List.of(kycDocumentModelOne, kycDocumentModelTwo)).build();
final List<KYCDocumentSellerInfoModel> successfullyPushedDocumentsList = List.of(kycDocumentOne);
testObj.cleanUpDocumentsFiles(successfullyPushedDocumentsList);
verify(fileOneMock).delete();
verify(fileTwoMock).delete();
assertThat(logTrackerStub.contains("Cleaning up done successfully!")).isTrue();
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceImplTest method pushDocuments_shouldDoNothingForKYCDocumentsInfoWithDocumentsNonFilled.
@Test
void pushDocuments_shouldDoNothingForKYCDocumentsInfoWithDocumentsNonFilled() {
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelOneStub = Mockito.spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_ONE).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_ONE))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelTwoStub = Mockito.spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_TWO).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_TWO))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
when(kycDocumentSellerInfoModelOneStub.areDocumentsFilled()).thenReturn(true);
when(kycDocumentSellerInfoModelTwoStub.areDocumentsFilled()).thenReturn(false);
when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelOneStub)).thenReturn(List.of(uploadDataOneMock));
when(hyperwalletSDKServiceMock.getHyperwalletInstance(Mockito.anyString())).thenReturn(hyperwalletClientMock);
final List<KYCDocumentSellerInfoModel> result = testObj.pushProofOfIdentityAndBusinessSellerDocuments(List.of(kycDocumentSellerInfoModelOneStub, kycDocumentSellerInfoModelTwoStub));
verify(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_ONE, List.of(uploadDataOneMock));
verify(hyperwalletClientMock, never()).uploadUserDocuments(USR_TOKEN_TWO, List.of(uploadDataTwoMock));
assertThat(result).containsExactly(markInfoAsSentToHyperwallet(kycDocumentSellerInfoModelOneStub));
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceImplTest method pushDocuments_shouldReturnOnlySuccessfulKYCDocumentInfoModelAPICalls.
@Test
void pushDocuments_shouldReturnOnlySuccessfulKYCDocumentInfoModelAPICalls() {
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelOKStub = Mockito.spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_ONE).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_ONE))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelKOStub = Mockito.spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_TWO).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_TWO))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
when(kycDocumentSellerInfoModelOKStub.areDocumentsFilled()).thenReturn(true);
when(kycDocumentSellerInfoModelKOStub.areDocumentsFilled()).thenReturn(true);
when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelOKStub)).thenReturn(List.of(uploadDataOneMock));
when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelKOStub)).thenReturn(List.of(uploadDataTwoMock));
when(hyperwalletSDKServiceMock.getHyperwalletInstance(Mockito.anyString())).thenReturn(hyperwalletClientMock);
doReturn(new HyperwalletUser()).when(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_ONE, List.of(uploadDataOneMock));
doThrow(new HyperwalletException("Something went wrong")).when(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_TWO, List.of(uploadDataTwoMock));
final List<KYCDocumentSellerInfoModel> result = testObj.pushProofOfIdentityAndBusinessSellerDocuments(List.of(kycDocumentSellerInfoModelOKStub, kycDocumentSellerInfoModelKOStub));
verify(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_ONE, List.of(uploadDataOneMock));
verify(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_TWO, List.of(uploadDataTwoMock));
assertThat(result).containsExactly(markInfoAsSentToHyperwallet(kycDocumentSellerInfoModelOKStub));
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceImplTest method pushDocuments_shouldReturnAllKYCDocumentInfoModelWhenAllMiraklAPICallsAreSuccessful.
@Test
void pushDocuments_shouldReturnAllKYCDocumentInfoModelWhenAllMiraklAPICallsAreSuccessful() {
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelOneStub = spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_ONE).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_ONE))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelTwoStub = Mockito.spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_TWO).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_TWO))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
when(kycDocumentSellerInfoModelOneStub.areDocumentsFilled()).thenReturn(true);
when(kycDocumentSellerInfoModelTwoStub.areDocumentsFilled()).thenReturn(true);
when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelOneStub)).thenReturn(List.of(uploadDataOneMock));
when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelTwoStub)).thenReturn(List.of(uploadDataTwoMock));
when(hyperwalletSDKServiceMock.getHyperwalletInstance(Mockito.anyString())).thenReturn(hyperwalletClientMock);
final List<KYCDocumentSellerInfoModel> result = testObj.pushProofOfIdentityAndBusinessSellerDocuments(List.of(kycDocumentSellerInfoModelOneStub, kycDocumentSellerInfoModelTwoStub));
verify(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_ONE, List.of(uploadDataOneMock));
verify(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_TWO, List.of(uploadDataTwoMock));
assertThat(result).containsExactlyInAnyOrder(markInfoAsSentToHyperwallet(kycDocumentSellerInfoModelOneStub), markInfoAsSentToHyperwallet(kycDocumentSellerInfoModelTwoStub));
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceMockImplTest method execute_shouldSendEmailNotificationWhenFailingFilesAreIncluded.
@Test
void execute_shouldSendEmailNotificationWhenFailingFilesAreIncluded() {
final KYCDocumentSellerInfoModel kycDocumentOne = KYCDocumentSellerInfoModel.builder().userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN))).clientUserId(SHOP_ID).proofOfAddress(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HYPERWALLET_KYC_IND_PROOF_OF_ADDRESS_FIELD, "BANK_STATEMENT"))).build();
HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
hyperwalletVerificationDocument.setCategory("category");
hyperwalletVerificationDocument.setCountry("ES");
hyperwalletVerificationDocument.setType("type");
hyperwalletVerificationDocument.setUploadFiles(Map.of("key1", "value1", "fail", "failFile"));
final Map<KYCDocumentSellerInfoModel, List<HyperwalletVerificationDocument>> kycDocumentOne1 = Map.of(kycDocumentOne, List.of(hyperwalletVerificationDocument));
final Map.Entry<KYCDocumentSellerInfoModel, 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]%n%s", String.join(",", SHOP_ID), HyperwalletLoggingErrorsUtil.stringify(new HyperwalletException("Something bad happened"))));
}
Aggregations