Search in sources :

Example 6 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue in project mirakl-hyperwallet-connector by paypal.

the class AbstractKYCUserStatusExecutorNotificationStrategyTest method updateShop_shouldCallMiraklApiModifyingKYCLetterOfAuthorization.

@Test
void updateShop_shouldCallMiraklApiModifyingKYCLetterOfAuthorization() {
    when(testObj.isKycAutomated()).thenReturn(true);
    when(kycUserStatusNotificationBodyModelMock.getClientUserId()).thenReturn(SHOP_ID);
    when(kycUserStatusNotificationBodyModelMock.getReasonsType()).thenReturn(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED));
    when(kycUserStatusNotificationBodyModelMock.getLetterOfAuthorizationStatus()).thenReturn(HyperwalletUser.LetterOfAuthorizationStatus.REQUIRED);
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdatedShopResponseMock);
    when(testObj.expectedKycMiraklStatus(kycUserStatusNotificationBodyModelMock)).thenReturn(MiraklShopKycStatus.REFUSED);
    when(kycRejectionReasonServiceMock.getRejectionReasonDescriptions(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED))).thenReturn(KYCRejectionReasonTypeEnum.getReasonHeader() + KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED.getReason() + KYCRejectionReasonTypeEnum.getReasonFooter());
    testObj.updateShop(kycUserStatusNotificationBodyModelMock);
    verify(kycRejectionReasonServiceMock).getRejectionReasonDescriptions(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED));
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopMockArgumentCaptor.capture());
    final MiraklUpdateShopsRequest request = miraklUpdateShopMockArgumentCaptor.getValue();
    assertThat(request.getShops()).hasSize(1);
    assertThat(request.getShops().get(0).getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
    final MiraklRequestAdditionalFieldValue additionalFieldValue = request.getShops().get(0).getAdditionalFieldValues().get(0);
    final MiraklSimpleRequestAdditionalFieldValue castedAdditionalFieldValue = (MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue;
    assertThat(castedAdditionalFieldValue.getCode()).isEqualTo(HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD);
    assertThat(castedAdditionalFieldValue.getValue()).isEqualTo("true");
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 7 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue in project mirakl-hyperwallet-connector by paypal.

the class AbstractKYCUserStatusExecutorNotificationStrategyTest method updateShop_whenIsKycManualFlow_shouldCallMiraklApiModifyingKYCWithoutUpdatingLetterOfAuthorizationAndVerificationStatus.

@Test
void updateShop_whenIsKycManualFlow_shouldCallMiraklApiModifyingKYCWithoutUpdatingLetterOfAuthorizationAndVerificationStatus() {
    when(testObj.isKycAutomated()).thenReturn(false);
    when(kycUserStatusNotificationBodyModelMock.getClientUserId()).thenReturn(SHOP_ID);
    when(kycUserStatusNotificationBodyModelMock.getReasonsType()).thenReturn(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED));
    lenient().when(kycUserStatusNotificationBodyModelMock.getVerificationStatus()).thenReturn(HyperwalletUser.VerificationStatus.REQUIRED);
    lenient().when(kycUserStatusNotificationBodyModelMock.getLetterOfAuthorizationStatus()).thenReturn(HyperwalletUser.LetterOfAuthorizationStatus.REQUIRED);
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdatedShopResponseMock);
    when(testObj.expectedKycMiraklStatus(kycUserStatusNotificationBodyModelMock)).thenReturn(MiraklShopKycStatus.REFUSED);
    when(kycRejectionReasonServiceMock.getRejectionReasonDescriptions(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED))).thenReturn(KYCRejectionReasonTypeEnum.getReasonHeader() + KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED.getReason() + KYCRejectionReasonTypeEnum.getReasonFooter());
    testObj.updateShop(kycUserStatusNotificationBodyModelMock);
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopMockArgumentCaptor.capture());
    final MiraklUpdateShopsRequest request = miraklUpdateShopMockArgumentCaptor.getValue();
    verify(kycRejectionReasonServiceMock).getRejectionReasonDescriptions(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED));
    assertThat(request.getShops()).hasSize(1);
    assertThat(request.getShops().get(0).getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValue = request.getShops().get(0).getAdditionalFieldValues();
    assertThat(additionalFieldValue).isNull();
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 8 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue in project mirakl-hyperwallet-connector by paypal.

the class AbstractKYCUserStatusExecutorNotificationStrategyTest method updateShop_whenIsKycAutomatedFlow_shouldCallMiraklApiModifyingKYCLetterOfAuthorizationAndVerificationStatus.

@Test
void updateShop_whenIsKycAutomatedFlow_shouldCallMiraklApiModifyingKYCLetterOfAuthorizationAndVerificationStatus() {
    when(testObj.isKycAutomated()).thenReturn(true);
    when(kycUserStatusNotificationBodyModelMock.getClientUserId()).thenReturn(SHOP_ID);
    when(kycUserStatusNotificationBodyModelMock.getReasonsType()).thenReturn(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED));
    when(kycUserStatusNotificationBodyModelMock.getVerificationStatus()).thenReturn(HyperwalletUser.VerificationStatus.REQUIRED);
    when(kycUserStatusNotificationBodyModelMock.getLetterOfAuthorizationStatus()).thenReturn(HyperwalletUser.LetterOfAuthorizationStatus.REQUIRED);
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdatedShopResponseMock);
    when(testObj.expectedKycMiraklStatus(kycUserStatusNotificationBodyModelMock)).thenReturn(MiraklShopKycStatus.REFUSED);
    when(kycRejectionReasonServiceMock.getRejectionReasonDescriptions(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED))).thenReturn(KYCRejectionReasonTypeEnum.getReasonHeader() + KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED.getReason() + KYCRejectionReasonTypeEnum.getReasonFooter());
    testObj.updateShop(kycUserStatusNotificationBodyModelMock);
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopMockArgumentCaptor.capture());
    final MiraklUpdateShopsRequest request = miraklUpdateShopMockArgumentCaptor.getValue();
    verify(kycRejectionReasonServiceMock).getRejectionReasonDescriptions(List.of(KYCRejectionReasonTypeEnum.LETTER_OF_AUTHORIZATION_REQUIRED));
    assertThat(request.getShops()).hasSize(1);
    assertThat(request.getShops().get(0).getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValue = request.getShops().get(0).getAdditionalFieldValues();
    assertThat(additionalFieldValue).hasSize(2);
    final List<String> additionalCodes = additionalFieldValue.stream().map(MiraklRequestAdditionalFieldValue::getCode).collect(Collectors.toList());
    assertThat(additionalCodes).containsExactlyInAnyOrder(HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD, HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 9 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method updateMiraklProofIdentityFlagStatus_whenStatusIsRequired_shouldUpdateMiraklWithProofOfIdentityNeeded.

@Test
void updateMiraklProofIdentityFlagStatus_whenStatusIsRequired_shouldUpdateMiraklWithProofOfIdentityNeeded() {
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(miraklUpdateShopsRequestArgumentCaptor.capture())).thenReturn(miraklUpdatedShopsMock);
    testObj.updateMiraklProofIdentityFlagStatus(MIRAKL_SHOP_ID, BSTK_PROOF_IDENTITY_FIELD, HyperwalletUser.VerificationStatus.REQUIRED);
    final MiraklUpdateShopsRequest result = miraklUpdateShopsRequestArgumentCaptor.getValue();
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValuesToBeChanged = result.getShops().get(0).getAdditionalFieldValues();
    assertThat(additionalFieldValuesToBeChanged).hasSize(1);
    final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue miraklSimpleRequestAdditionalFieldValue = (MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValuesToBeChanged.get(0);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getCode()).isEqualTo(BSTK_PROOF_IDENTITY_FIELD);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getValue()).isEqualTo("true");
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 10 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method updateMiraklProofIdentityFlagStatus_whenStatusIsNotRequired_shouldUpdateMiraklWithProofOfIdentityNotNeeded.

@Test
void updateMiraklProofIdentityFlagStatus_whenStatusIsNotRequired_shouldUpdateMiraklWithProofOfIdentityNotNeeded() {
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(miraklUpdateShopsRequestArgumentCaptor.capture())).thenReturn(miraklUpdatedShopsMock);
    testObj.updateMiraklProofIdentityFlagStatus(MIRAKL_SHOP_ID, BSTK_PROOF_IDENTITY_FIELD, HyperwalletUser.VerificationStatus.NOT_REQUIRED);
    final MiraklUpdateShopsRequest result = miraklUpdateShopsRequestArgumentCaptor.getValue();
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValuesToBeChanged = result.getShops().get(0).getAdditionalFieldValues();
    assertThat(additionalFieldValuesToBeChanged).hasSize(1);
    final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue miraklSimpleRequestAdditionalFieldValue = (MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValuesToBeChanged.get(0);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getCode()).isEqualTo(BSTK_PROOF_IDENTITY_FIELD);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getValue()).isEqualTo("false");
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Aggregations

MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)16 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)16 Test (org.junit.jupiter.api.Test)12 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)9 MiraklSimpleRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)6 MiraklException (com.mirakl.client.core.exception.MiraklException)3 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)3 KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)3 MiraklBusinessStakeholderDocumentsExtractService (com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService)3 Collectors (java.util.stream.Collectors)3 Slf4j (lombok.extern.slf4j.Slf4j)3 DisplayName (org.junit.jupiter.api.DisplayName)3 Service (org.springframework.stereotype.Service)3 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)2 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)2 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)2 KYCConstants (com.paypal.kyc.model.KYCConstants)2 List (java.util.List)2 CollectionUtils (org.apache.commons.collections4.CollectionUtils)2 StringUtils (com.mchange.v2.lang.StringUtils)1