use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method updateMiraklProofIdentityFlagStatus_whenAPICallThrowsException_shouldThrowException.
@Test
void updateMiraklProofIdentityFlagStatus_whenAPICallThrowsException_shouldThrowException() {
final MiraklException exception = new MiraklException("An error has occurred");
when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(miraklUpdateShopsRequestArgumentCaptor.capture())).thenThrow(exception);
final Throwable throwable = catchThrowable(() -> testObj.updateMiraklProofIdentityFlagStatus(MIRAKL_SHOP_ID, BSTK_PROOF_IDENTITY_FIELD, HyperwalletUser.VerificationStatus.REQUIRED));
assertThat(throwable).isEqualTo(exception);
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");
}
use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class AbstractUserDocumentFlagsStrategyTest method fillMiraklProofIdentityOrBusinessFlagStatus_shouldSetFlagProofIdentificationToTrueInMirakl.
@Test
void fillMiraklProofIdentityOrBusinessFlagStatus_shouldSetFlagProofIdentificationToTrueInMirakl() {
// @formatter:off
final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.INDIVIDUAL).verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED).build();
// @formatter:on
testObj.fillMiraklProofIdentityOrBusinessFlagStatus(kycUserDocumentFlagsNotificationBodyModel);
verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopsRequestArgumentCaptor.capture());
final MiraklUpdateShopsRequest updateShopRequest = miraklUpdateShopsRequestArgumentCaptor.getValue();
final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue additionalValue = new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, "true");
assertThat(updateShopRequest.getShops()).hasSize(1);
final MiraklUpdateShop shop = updateShopRequest.getShops().get(0);
assertThat(shop.getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = shop.getAdditionalFieldValues();
assertThat(additionalFieldValues).hasSize(1);
final MiraklRequestAdditionalFieldValue additionalFieldValue = additionalFieldValues.get(0);
assertThat(additionalFieldValue.getCode()).isEqualTo(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
assertThat(additionalFieldValue).isInstanceOf(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class);
assertThat(((MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue).getValue()).isEqualTo(Boolean.TRUE.toString());
}
use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategyTest method execute_shouldCallUpdateShopWithBusinessStakeHolderCustomValueFlags.
@Test
void execute_shouldCallUpdateShopWithBusinessStakeHolderCustomValueFlags() {
// @formatter:off
final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).userToken(USER_TOKEN).clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.BUSINESS).businessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.REQUIRED).build();
// @formatter:on
when(hyperwalletBusinessStakeholderExtractServiceMock.getKYCRequiredVerificationBusinessStakeHolders(HYPERWALLET_PROGRAM, USER_TOKEN)).thenReturn(List.of(BUSINESS_STAKE_HOLDER_TOKEN));
when(miraklBusinessStakeholderDocumentsExtractServiceMock.getKYCCustomValuesRequiredVerificationBusinessStakeholders(SHOP_ID, List.of(BUSINESS_STAKE_HOLDER_TOKEN))).thenReturn(List.of(HW_STAKEHOLDER_PROOF_IDENTITY_TYPE_1));
testObj.execute(kycUserDocumentFlagsNotificationBodyModel);
verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopsRequestArgumentCaptor.capture());
final MiraklUpdateShopsRequest miraklRequest = miraklUpdateShopsRequestArgumentCaptor.getValue();
assertThat(miraklRequest.getShops()).hasSize(1);
final MiraklUpdateShop updateShop = miraklRequest.getShops().get(0);
assertThat(updateShop.getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = updateShop.getAdditionalFieldValues();
assertThat(additionalFieldValues).hasSize(1);
final MiraklRequestAdditionalFieldValue additionalFieldValue = additionalFieldValues.get(0);
assertThat(additionalFieldValue.getCode()).isEqualTo(HW_STAKEHOLDER_PROOF_IDENTITY_TYPE_1);
assertThat(additionalFieldValue).isInstanceOf(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class);
assertThat(((MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue).getValue()).isEqualTo(Boolean.TRUE.toString());
}
use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategy method fillMiraklProofIdentityOrBusinessFlagStatus.
protected void fillMiraklProofIdentityOrBusinessFlagStatus(final KYCUserDocumentFlagsNotificationBodyModel source, final List<String> kycCustomValuesRequiredVerificationBusinessStakeholders) {
if (CollectionUtils.isNotEmpty(kycCustomValuesRequiredVerificationBusinessStakeholders)) {
final MiraklUpdateShop updateShop = new MiraklUpdateShop();
final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = kycCustomValuesRequiredVerificationBusinessStakeholders.stream().map(kycCustomValueRequiredVerification -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(kycCustomValueRequiredVerification, Boolean.TRUE.toString())).collect(Collectors.toList());
updateShop.setShopId(Long.valueOf(source.getClientUserId()));
updateShop.setAdditionalFieldValues(additionalFieldValues);
try {
log.info("Updating KYC proof of identity flag in Mirakl for business Stakeholder for shopId [{}]", source.getClientUserId());
final MiraklUpdateShopsRequest miraklUpdateShopsRequest = new MiraklUpdateShopsRequest(List.of(updateShop));
miraklMarketplacePlatformOperatorApiClient.updateShops(miraklUpdateShopsRequest);
log.info("Proof of identity flag updated for business Stakeholder for shopId [{}]", source.getClientUserId());
} catch (final MiraklException ex) {
log.error("Something went wrong updating KYC business stakeholder information of shop [{}]. Details [{}]", source.getClientUserId(), ex.getMessage());
mailNotificationUtil.sendPlainTextEmail("Issue detected updating KYC business stakeholder information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC business stakeholder information for shop [%s]%n%s", source.getClientUserId(), MiraklLoggingErrorsUtil.stringify(ex)));
// Rethrow exception to handle it in AbstractNotificationListener
throw ex;
}
}
}
Aggregations