Search in sources :

Example 16 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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 17 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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 18 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.

the class BusinessKYCUserLOAStatusNotificationStrategyTest method execute_shouldCallUpdateMiraklLOAStatus.

@Test
void execute_shouldCallUpdateMiraklLOAStatus() {
    when(kycHyperwalletApiConfigMock.getUserStoreTokens()).thenReturn(USER_STORE_TOKENS);
    when(hyperwalletSDKServiceMock.getHyperwalletInstance(anyString())).thenReturn(hyperwalletMock);
    when(kycBusinessStakeholderStatusNotificationBodyModelMock.getUserToken()).thenReturn(USER_TOKEN);
    when(hyperwalletMock.getUser(USER_TOKEN)).thenReturn(hyperwalletUserMock);
    when(hyperwalletUserMock.getClientUserId()).thenReturn(MIRAKL_SHOP_ID);
    when(hyperwalletUserMock.getLetterOfAuthorizationStatus()).thenReturn(HyperwalletUser.LetterOfAuthorizationStatus.REQUIRED);
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(miraklUpdateShopsRequestArgumentCaptor.capture())).thenReturn(miraklUpdatedShopsMock);
    testObj.execute(kycBusinessStakeholderStatusNotificationBodyModelMock);
    final MiraklUpdateShopsRequest miraklUpdateShopsRequestArgumentCaptorValue = miraklUpdateShopsRequestArgumentCaptor.getValue();
    final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue result = (MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) miraklUpdateShopsRequestArgumentCaptorValue.getShops().get(0).getAdditionalFieldValues().get(0);
    assertThat(result.getCode()).isEqualTo(KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD);
    assertThat(result.getValue()).isEqualTo(Boolean.TRUE.toString());
}
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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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 20 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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)28 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)20 Test (org.junit.jupiter.api.Test)16 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)15 MiraklSimpleRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)9 MiraklException (com.mirakl.client.core.exception.MiraklException)6 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)5 MiraklApiException (com.mirakl.client.core.exception.MiraklApiException)3 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)3 KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)3 Collectors (java.util.stream.Collectors)3 Slf4j (lombok.extern.slf4j.Slf4j)3 CollectionUtils (org.apache.commons.collections4.CollectionUtils)3 DisplayName (org.junit.jupiter.api.DisplayName)3 Service (org.springframework.stereotype.Service)3 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)2 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)2 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)2 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)2 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)2