Search in sources :

Example 1 with BusinessStakeHolderModel

use of com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel in project mirakl-hyperwallet-connector by paypal.

the class HyperWalletUpdateBusinessStakeHolderServiceStrategyTest method execute_shouldReturnUpdatedHyperWalletBusinessStakeHolder.

@Test
void execute_shouldReturnUpdatedHyperWalletBusinessStakeHolder() {
    when(businessStakeHolderModelHyperwalletBusinessStakeholderConverterMock.convert(businessStakeHolderMock)).thenReturn(hyperwalletBusinessStakeholderMock);
    when(hyperwalletClientMock.updateBusinessStakeholder(TOKEN, hyperwalletBusinessStakeholderMock)).thenReturn(hyperwalletBusinessStakeholderResponseMock);
    when(businessStakeHolderMock.getUserToken()).thenReturn(TOKEN);
    when(businessStakeHolderMock.getHyperwalletProgram()).thenReturn(HYPERWALLET_PROGRAM);
    when(hyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletClientMock);
    final BusinessStakeHolderModel result = testObj.execute(businessStakeHolderMock);
    assertThat(result).isEqualTo(businessStakeHolderMock);
}
Also used : BusinessStakeHolderModel(com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel) Test(org.junit.jupiter.api.Test)

Example 2 with BusinessStakeHolderModel

use of com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel in project mirakl-hyperwallet-connector by paypal.

the class BusinessStakeholderExtractServiceImplTest method extractBusinessStakeHolders_shouldReturnAllBusinessStakeHoldersWithDifferentSellers.

@Test
void extractBusinessStakeHolders_shouldReturnAllBusinessStakeHoldersWithDifferentSellers() {
    final BusinessStakeHolderModel stkOne = BusinessStakeHolderModel.builder().userToken(TOKEN_1).clientUserId("0001").token("STK1_TOKEN").firstName(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(BusinessStakeHolderConstants.FIRST_NAME, "john")), 1).build();
    final BusinessStakeHolderModel stkTwo = BusinessStakeHolderModel.builder().userToken(TOKEN_2).firstName(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(BusinessStakeHolderConstants.FIRST_NAME, "susan")), 1).clientUserId("0002").token("STK2_TOKEN").build();
    final SellerModel sellerModelOne = SellerModel.builder().token(TOKEN_1).businessStakeHolderDetails(List.of(stkOne)).clientUserId(CLIENT_ID_1).build();
    final SellerModel sellerModelTwo = SellerModel.builder().token(TOKEN_2).businessStakeHolderDetails(List.of(stkTwo)).clientUserId(CLIENT_ID_2).build();
    final BusinessStakeHolderModel createdStkOneMock = stkOne.toBuilder().justCreated(true).build();
    final BusinessStakeHolderModel updatedStkTwoMock = stkTwo.toBuilder().build();
    when(hyperWalletBusinessStakeHolderServiceExecutorMock.execute(stkOne)).thenReturn(createdStkOneMock);
    when(hyperWalletBusinessStakeHolderServiceExecutorMock.execute(stkTwo)).thenReturn(updatedStkTwoMock);
    testObj.extractBusinessStakeHolders(List.of(sellerModelOne, sellerModelTwo));
    verify(hyperWalletBusinessStakeHolderServiceExecutorMock).execute(stkOne);
    verify(hyperWalletBusinessStakeHolderServiceExecutorMock).execute(stkTwo);
    verify(miraklBusinessStakeholderExtractServiceMock).updateBusinessStakeholderToken("0001", List.of(createdStkOneMock));
}
Also used : BusinessStakeHolderModel(com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel) MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) SellerModel(com.paypal.sellers.sellersextract.model.SellerModel) Test(org.junit.jupiter.api.Test)

Example 3 with BusinessStakeHolderModel

use of com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel in project mirakl-hyperwallet-connector by paypal.

the class ListAdditionalFieldValuesToBusinessStakeHolderModelConverterTest method convert_shouldReturnBusinessStakeHolderModelBasedOnValuesOfMiraklShop.

@Test
void convert_shouldReturnBusinessStakeHolderModelBasedOnValuesOfMiraklShop() {
    final List<MiraklAdditionalFieldValue> miraklAdditionalFieldValues = List.of(miraklAdditionalFieldValueOneMock);
    doReturn(businessStakeHolderModelBuilderMock).when(testObj).getBuilder();
    when(sellersMiraklApiConfigMock.getTimeZone()).thenReturn(UTC);
    when(businessStakeHolderModelBuilderMock.timeZone(UTC)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.userToken(miraklAdditionalFieldValues)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.clientUserId(CLIENT_ID)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.token(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.businessContact(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.director(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.ubo(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.smo(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.firstName(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.middleName(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.lastName(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.dateOfBirth(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.countryOfBirth(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.countryOfNationality(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.gender(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.phoneNumber(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.mobileNumber(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.email(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.governmentId(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.governmentIdType(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.driversLicenseId(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.addressLine1(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.addressLine2(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.city(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.stateProvince(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.country(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.postalCode(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.build()).thenReturn(businessStakeHolderModelMock);
    when(businessStakeHolderModelBuilderMock.stkId(1)).thenReturn(businessStakeHolderModelBuilderMock);
    when(businessStakeHolderModelBuilderMock.hyperwalletProgram(miraklAdditionalFieldValues)).thenReturn(businessStakeHolderModelBuilderMock);
    final BusinessStakeHolderModel result = testObj.convert(Triple.of(miraklAdditionalFieldValues, BUSINESS_STAKE_HOLDER_NUMBER, CLIENT_ID));
    verifyAttributes(miraklAdditionalFieldValues);
    assertThat(result).isEqualTo(businessStakeHolderModelMock);
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) BusinessStakeHolderModel(com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel) Test(org.junit.jupiter.api.Test)

Example 4 with BusinessStakeHolderModel

use of com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderExtractServiceImpl method createMiraklUpdateFieldRequestForStakeholders.

private MiraklUpdateShop createMiraklUpdateFieldRequestForStakeholders(final String clientUserId, final List<BusinessStakeHolderModel> businessStakeHolderModels) {
    final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
    miraklUpdateShop.setShopId(Long.valueOf(clientUserId));
    final List<String> stakeholderTokens = new ArrayList<>();
    final List<MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue> stakeholdersTokenFields = businessStakeHolderModels.stream().map(businessStakeHolderModel -> {
        stakeholderTokens.add(businessStakeHolderModel.getToken());
        return new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(BusinessStakeHolderConstants.TOKEN + HYPHEN + businessStakeHolderModel.getStkId(), businessStakeHolderModel.getToken());
    }).collect(Collectors.toList());
    log.info("Storing business stakeholder tokens [{}] for shop [{}]", String.join(",", stakeholderTokens), clientUserId);
    miraklUpdateShop.setAdditionalFieldValues(Collections.unmodifiableList(stakeholdersTokenFields));
    return miraklUpdateShop;
}
Also used : MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) BusinessStakeHolderModel(com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel) MiraklBusinessStakeholderExtractService(com.paypal.sellers.sellersextract.service.MiraklBusinessStakeholderExtractService) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) BusinessStakeHolderConstants(com.paypal.sellers.sellersextract.model.BusinessStakeHolderConstants) ArrayList(java.util.ArrayList) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) Service(org.springframework.stereotype.Service) CollectionUtils(org.springframework.util.CollectionUtils) Collections(java.util.Collections) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) ERROR_MESSAGE_PREFIX(com.paypal.sellers.sellersextract.service.impl.BusinessStakeholderExtractServiceImpl.ERROR_MESSAGE_PREFIX) ArrayList(java.util.ArrayList) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)

Example 5 with BusinessStakeHolderModel

use of com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel in project mirakl-hyperwallet-connector by paypal.

the class HyperWalletCreateBusinessStakeHolderServiceStrategyTest method execute_shouldReturnCreatedHyperWalletBusinessStakeHolder.

@Test
void execute_shouldReturnCreatedHyperWalletBusinessStakeHolder() {
    when(businessStakeHolderModelHyperwalletBusinessStakeholderConverterMock.convert(businessStakeHolderMock)).thenReturn(hyperwalletBusinessStakeholderMock);
    when(hyperwalletClientMock.createBusinessStakeholder(TOKEN, hyperwalletBusinessStakeholderMock)).thenReturn(hyperwalletBusinessStakeholderResponseMock);
    when(hyperwalletBusinessStakeholderResponseMock.getToken()).thenReturn(BUSINESS_STAKE_HOLDER_TOKEN);
    when(businessStakeHolderMock.getUserToken()).thenReturn(TOKEN);
    when(businessStakeHolderMock.toBuilder()).thenReturn(businessStakeHolderBuilderMock);
    when(businessStakeHolderBuilderMock.token(BUSINESS_STAKE_HOLDER_TOKEN)).thenReturn(businessStakeHolderBuilderMock);
    when(businessStakeHolderBuilderMock.justCreated(true)).thenReturn(businessStakeHolderBuilderMock);
    when(businessStakeHolderBuilderMock.build()).thenReturn(businessStakeHolderResponseMock);
    when(businessStakeHolderMock.getHyperwalletProgram()).thenReturn(HYPERWALLET_PROGRAM);
    when(hyperwalletSDKServiceMock.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletClientMock);
    final BusinessStakeHolderModel result = testObj.execute(businessStakeHolderMock);
    assertThat(result).isEqualTo(businessStakeHolderResponseMock);
}
Also used : BusinessStakeHolderModel(com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel) Test(org.junit.jupiter.api.Test)

Aggregations

BusinessStakeHolderModel (com.paypal.sellers.sellersextract.model.BusinessStakeHolderModel)5 Test (org.junit.jupiter.api.Test)4 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)2 MiraklApiException (com.mirakl.client.core.exception.MiraklApiException)1 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)1 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)1 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)1 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)1 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)1 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)1 BusinessStakeHolderConstants (com.paypal.sellers.sellersextract.model.BusinessStakeHolderConstants)1 SellerModel (com.paypal.sellers.sellersextract.model.SellerModel)1 MiraklBusinessStakeholderExtractService (com.paypal.sellers.sellersextract.service.MiraklBusinessStakeholderExtractService)1 ERROR_MESSAGE_PREFIX (com.paypal.sellers.sellersextract.service.impl.BusinessStakeholderExtractServiceImpl.ERROR_MESSAGE_PREFIX)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Service (org.springframework.stereotype.Service)1