Search in sources :

Example 6 with KYCDocumentSellerInfoModel

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();
}
Also used : KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) KYCDocumentModel(com.paypal.kyc.model.KYCDocumentModel) Test(org.junit.jupiter.api.Test)

Example 7 with KYCDocumentSellerInfoModel

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));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) Test(org.junit.jupiter.api.Test)

Example 8 with KYCDocumentSellerInfoModel

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));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) Test(org.junit.jupiter.api.Test)

Example 9 with KYCDocumentSellerInfoModel

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));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) Test(org.junit.jupiter.api.Test)

Example 10 with KYCDocumentSellerInfoModel

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"))));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) List(java.util.List) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)17 Test (org.junit.jupiter.api.Test)10 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)7 HyperwalletVerificationDocument (com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)6 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)5 Map (java.util.Map)4 Strategy (com.paypal.infrastructure.strategy.Strategy)3 KYCDocumentCategoryEnum (com.paypal.kyc.model.KYCDocumentCategoryEnum)3 Objects (java.util.Objects)3 Collectors (java.util.stream.Collectors)3 Service (org.springframework.stereotype.Service)3 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)2 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)2 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)2 List (java.util.List)2 ObjectUtils (org.springframework.util.ObjectUtils)2 Gson (com.google.gson.Gson)1 Hyperwallet (com.hyperwallet.clientsdk.Hyperwallet)1 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)1 MiraklException (com.mirakl.client.core.exception.MiraklException)1