use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceMockImplTest method execute_shouldRunPushDocumentsToMockServer.
@Test
void execute_shouldRunPushDocumentsToMockServer() {
final KYCDocumentSellerInfoModel kycDocumentOne = KYCDocumentSellerInfoModel.builder().userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN))).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"));
when(testObj.getMockServerUrl()).thenReturn(MOCK_SERVER_URL);
final Map<KYCDocumentSellerInfoModel, 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.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceImplTest method pushDocuments_shouldSendEmailNotificationWhenHyperWalletExceptionIsThrown.
@Test
void pushDocuments_shouldSendEmailNotificationWhenHyperWalletExceptionIsThrown() {
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(kycDocumentSellerInfoModelKOStub.areDocumentsFilled()).thenReturn(true);
when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelKOStub)).thenReturn(List.of(uploadDataTwoMock));
when(hyperwalletSDKServiceMock.getHyperwalletInstance(Mockito.anyString())).thenReturn(hyperwalletClientMock);
HyperwalletException hyperwalletException = new HyperwalletException("Something went wrong");
doThrow(hyperwalletException).when(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_TWO, List.of(uploadDataTwoMock));
testObj.pushProofOfIdentityAndBusinessSellerDocuments(List.of(kycDocumentSellerInfoModelKOStub));
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(",", kycDocumentSellerInfoModelKOStub.getClientUserId()), HyperwalletLoggingErrorsUtil.stringify(hyperwalletException)));
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellerDocumentsExtractServiceImplTest method setFlagToPushSellerDocumentsToFalse_shouldSendEmailNotificationWhenMiraklExceptionIsThrown.
@Test
void setFlagToPushSellerDocumentsToFalse_shouldSendEmailNotificationWhenMiraklExceptionIsThrown() {
final KYCDocumentSellerInfoModel kycDocumentOne = KYCDocumentSellerInfoModel.builder().clientUserId("2000").build();
final List<KYCDocumentSellerInfoModel> successfullyPushedDocumentsList = List.of(kycDocumentOne);
final MiraklException miraklException = new MiraklException("Something went wrong");
doThrow(miraklException).when(miraklMarketplacePlatformOperatorApiClientMock).updateShops(any(MiraklUpdateShopsRequest.class));
testObj.setFlagToPushProofOfIdentityAndBusinessSellerDocumentsToFalse(successfullyPushedDocumentsList);
verify(kycMailNotificationUtilMock).sendPlainTextEmail("Issue setting push document flags to false in Mirakl", String.format("Something went wrong setting push document flag to false in Mirakl for shop Id [2000]%n%s", String.join(",", MiraklLoggingErrorsUtil.stringify(miraklException))));
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellerDocumentsExtractServiceImplTest method setFlagToPushSellerDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam.
@Test
void setFlagToPushSellerDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam() {
final KYCDocumentSellerInfoModel kycDocumentOne = KYCDocumentSellerInfoModel.builder().clientUserId("2000").build();
final KYCDocumentSellerInfoModel kycDocumentTwo = KYCDocumentSellerInfoModel.builder().clientUserId("2001").build();
final List<KYCDocumentSellerInfoModel> successfullyPushedDocumentsList = List.of(kycDocumentOne, kycDocumentTwo);
when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdateShopsMock);
final Optional<MiraklUpdatedShops> result = testObj.setFlagToPushProofOfIdentityAndBusinessSellerDocumentsToFalse(successfullyPushedDocumentsList);
verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopArgumentCaptor.capture());
final MiraklUpdateShopsRequest miraklUpdateShopRequest = miraklUpdateShopArgumentCaptor.getValue();
final List<Long> updatedSellerIdList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getShopId).collect(Collectors.toList());
final List<String> updatedFlagValueList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getAdditionalFieldValues).flatMap(Collection::stream).filter(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::isInstance).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::cast).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue::getValue).collect(Collectors.toList());
final List<String> updatedFlagCodeList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getAdditionalFieldValues).flatMap(Collection::stream).filter(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::isInstance).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::cast).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue::getCode).collect(Collectors.toList());
assertThat(updatedSellerIdList).containsExactlyInAnyOrder(2000L, 2001L);
assertThat(updatedFlagValueList).containsExactlyInAnyOrder("false", "false");
assertThat(updatedFlagCodeList).containsExactlyInAnyOrder(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
assertThat(result).hasValue(miraklUpdateShopsMock);
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellerDocumentDownloadExtractServiceImpl method getDocumentsSelectedBySeller.
/**
* {@inheritDoc}
*/
@Override
public KYCDocumentSellerInfoModel getDocumentsSelectedBySeller(final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel) {
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelWithMiraklShops = populateMiraklShopDocuments(kycDocumentSellerInfoModel);
if (!kycDocumentSellerInfoModelWithMiraklShops.existsDocumentInMirakl()) {
log.warn("Some needed documents are missing for shop [{}], skipping pushing all documents to hyperwallet", kycDocumentSellerInfoModelWithMiraklShops.getClientUserId());
return kycDocumentSellerInfoModelWithMiraklShops;
}
final List<KYCDocumentModel> extractedDocumentsSelectedBySeller = miraklKYCSelectionDocumentStrategyExecutor.execute(kycDocumentSellerInfoModelWithMiraklShops).stream().flatMap(List::stream).collect(Collectors.toList());
return kycDocumentSellerInfoModelWithMiraklShops.toBuilder().documents(extractedDocumentsSelectedBySeller).build();
}
Aggregations