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);
}
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));
}
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);
}
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;
}
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);
}
Aggregations