From 6216c70099965c1118cc24e1e0b350cb4974bb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Polo=20Guti=C3=A9rrez?= Date: Fri, 15 Mar 2024 12:38:48 +0000 Subject: [PATCH] Release 5.2.0 --- .../main/groovy/hmc.lib-conventions.gradle | 2 +- .../payout-paymentstatus-apicalls.adoc | 1 + .../notifications/notifications-retry.adoc | 1 - docs/package.json | 3 + .../resources/application-test.properties | 2 + .../src/main/resources/application.properties | 6 ++ .../PaymentNotificationConfig.java | 3 + .../AcceptedPaymentNotificationStrategy.java | 2 + ...ceptedPaymentNotificationStrategyTest.java | 29 +++++++ .../NotificationsRepositoryImpl.java | 5 +- .../NotificationProcessingServiceImpl.java | 3 +- .../evaluators/predicates/IsDuplicated.java | 4 +- .../NotificationsRepositoryImplTest.java | 20 ++--- ...NotificationProcessingServiceImplTest.java | 7 +- .../predicates/IsDuplicatedTest.java | 4 +- hmc-observability/build.gradle | 2 +- .../mirakl/MiraklTrafficAuditorAdapter.java | 9 ++- ...oABABankAccountModelConverterStrategy.java | 7 +- ...dianBankAccountModelConverterStrategy.java | 7 +- ...IBANBankAccountModelConverterStrategy.java | 7 +- ...ToUKBankAccountModelConverterStrategy.java | 7 +- ...lShopToIndividualSellerModelConverter.java | 5 +- ...hopToProfessionalSellerModelConverter.java | 51 ++++++++++-- ...tractMiraklShopToSellerModelConverter.java | 10 ++- ...SellerModelToHyperWalletUserConverter.java | 1 + .../sellers/utils/LanguageConverter.java | 47 +++++++++++ ...BankAccountModelConverterStrategyTest.java | 17 ++-- ...BankAccountModelConverterStrategyTest.java | 17 ++-- ...BankAccountModelConverterStrategyTest.java | 29 +++---- ...BankAccountModelConverterStrategyTest.java | 17 ++-- ...pToIndividualSellerModelConverterTest.java | 6 +- ...oProfessionalSellerModelConverterTest.java | 78 ++++++++++++++++--- ...pToIndividualSellerModelConverterTest.java | 26 +++++-- ...erModelToHyperWalletUserConverterTest.java | 10 ++- .../sellers/utils/LanguageConverterTest.java | 67 ++++++++++++++++ .../resources/application-test.properties | 6 ++ 36 files changed, 416 insertions(+), 102 deletions(-) create mode 100644 hmc-sellers/src/main/java/com/paypal/sellers/utils/LanguageConverter.java create mode 100644 hmc-sellers/src/test/java/com/paypal/sellers/utils/LanguageConverterTest.java diff --git a/buildSrc/src/main/groovy/hmc.lib-conventions.gradle b/buildSrc/src/main/groovy/hmc.lib-conventions.gradle index f52112f5..cd6529f5 100644 --- a/buildSrc/src/main/groovy/hmc.lib-conventions.gradle +++ b/buildSrc/src/main/groovy/hmc.lib-conventions.gradle @@ -10,5 +10,5 @@ bootJar { dependencies { api 'com.hyperwallet:sdk:2.4.3' - api 'com.mirakl:mmp-sdk-operator:6.37.0' + api 'com.mirakl:mmp-sdk-operator:7.2.0' } diff --git a/docs/content/modules/payout/pages/paymentstatus/payout-paymentstatus-apicalls.adoc b/docs/content/modules/payout/pages/paymentstatus/payout-paymentstatus-apicalls.adoc index a37928a1..6c82b008 100644 --- a/docs/content/modules/payout/pages/paymentstatus/payout-paymentstatus-apicalls.adoc +++ b/docs/content/modules/payout/pages/paymentstatus/payout-paymentstatus-apicalls.adoc @@ -12,4 +12,5 @@ a| * `invoice_id`: invoice identifier * `currency_iso_code`: ISO code for the currency used in the payment. * `amount`: Amount of the invoice. * `transaction_date`: Invoice transaction date. +* `confirm_all_linked_manual_documents`: Confirm the payment of each manual accounting document present in the billing cycle. |=== \ No newline at end of file diff --git a/docs/content/modules/reference/pages/notifications/notifications-retry.adoc b/docs/content/modules/reference/pages/notifications/notifications-retry.adoc index 5b27ad61..677d7702 100644 --- a/docs/content/modules/reference/pages/notifications/notifications-retry.adoc +++ b/docs/content/modules/reference/pages/notifications/notifications-retry.adoc @@ -23,7 +23,6 @@ The connector reads the configuration from the following configuration variables * `PAYPAL_HYPERWALLET_MAX_AMOUNT_OF_NOTIFICATION_RETRIES`, determines the maximum number of attempts allowed for each notification. Set to `5` by default * `PAYPAL_HYPERWALLET_RETRY_FAILED_NOTIFICATIONS_CRON_EXPRESSION`, used to configure the periodicity of the retry job. - === Email alerts The connector sends an email to the operator when all the retries of a notification fails. The email includes the following details: diff --git a/docs/package.json b/docs/package.json index cb426420..3b7054ac 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,4 +1,7 @@ { + "scripts": { + "build": "antora --fetch --to-dir build antora-playbook.yml" + }, "devDependencies": { "@antora/cli": "3.0.3", "@antora/site-generator": "3.0.3" diff --git a/hmc-app/src/integrationTest/resources/application-test.properties b/hmc-app/src/integrationTest/resources/application-test.properties index 8175c2eb..07328443 100644 --- a/hmc-app/src/integrationTest/resources/application-test.properties +++ b/hmc-app/src/integrationTest/resources/application-test.properties @@ -20,3 +20,5 @@ hmc.hyperwallet.programs.userTokens = userToken hmc.hyperwallet.programs.paymentTokens = paymentToken hmc.hyperwallet.programs.bankAccountTokens = bankAccountToken hmc.hyperwallet.programs.rootToken = prg-1fb3df0d-787b-4bbd-9eb7-1d9fe8ed6c8e + +hmc.webhooks.payments.confirm-linked-manual-documents = true diff --git a/hmc-app/src/main/resources/application.properties b/hmc-app/src/main/resources/application.properties index f4f7dcd8..87ee4220 100644 --- a/hmc-app/src/main/resources/application.properties +++ b/hmc-app/src/main/resources/application.properties @@ -118,6 +118,7 @@ hmc.toggle-features.http-capture = ${PAYPAL_HYPERWALLET_HTTP hmc.webhooks.payments.failure-statuses = FAILED,RECALLED,RETURNED,EXPIRED,UNCLAIMED,CANCELLED hmc.webhooks.payments.accepted-statuses = COMPLETED +hmc.webhooks.payments.confirm-linked-manual-documents = ${PAYPAL_HYPERWALLET_CONFIRM_LINKED_MANUAL_DOCUMENTS:true} hmc.webhooks.routing-keys.payments = PAYMENTS hmc.webhooks.routing-keys.kyc-users = USERS.UPDATED.VERIFICATION_STATUS hmc.webhooks.routing-keys.kyc-bstk = USERS.BUSINESS_STAKEHOLDERS @@ -130,3 +131,8 @@ hmc.startup-checks.exit-on-fail = ${PAYPAL_HMC_STARTUPCHECK hmc.financial-reports.outputdir = ${PAYPAL_HYPERWALLET_FINANCIAL_REPORTS_OUTPUT_DIR:./financial-reports} hmc.financial-reports.header = braintreeCommerceOrderId,miraklOrderId,miraklSellerId,miraklTransactionLineId,miraklTransactionTime,TransactionType,braintreeAmount,miraklDebitAmount,miraklCreditAmount,currencyIsoCode,braintreeTransactionId,braintreeTransactionTime hmc.financial-reports.filename-prefix = financialReport + +hmc.hyperwallet.supported.languages = en,bg,zh,hr,cs,nl,fr,de,el,hu,is,id,in,it,ja,ko,lv,mk,ms,mn,pl,pt,ro,ru,sk,sl,es,sv,th,tr,uk,vi +hmc.hyperwallet.default.language = en + +hmc.hyperwallet.countries.not.local.tax = BES,CUB,CUW,DJI,ERI,GUM,KOR,LBR,MYX.PRI,SLB,SSD,TLS,TUV,USA,YEM diff --git a/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/configuration/PaymentNotificationConfig.java b/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/configuration/PaymentNotificationConfig.java index 492d7c8f..291fc938 100644 --- a/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/configuration/PaymentNotificationConfig.java +++ b/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/configuration/PaymentNotificationConfig.java @@ -19,4 +19,7 @@ public class PaymentNotificationConfig { @Value("#{'${hmc.webhooks.payments.accepted-statuses}'}") private Set acceptedStatuses; + @Value("#{'${hmc.webhooks.payments.confirm-linked-manual-documents}'}") + private boolean confirmLinkedManualDocuments; + } diff --git a/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategy.java b/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategy.java index 5615dc50..6efd3d40 100644 --- a/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategy.java +++ b/hmc-invoices/src/main/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategy.java @@ -62,6 +62,8 @@ protected MiraklConfirmAccountingDocumentPaymentRequest createPaymentConfirmatio miraklAccountingDocumentPaymentConfirmation .setTransactionDate(DateUtil.convertToDate(paymentNotificationBodyModel.getCreatedOn(), HyperWalletConstants.HYPERWALLET_DATE_FORMAT, DateUtil.TIME_UTC)); + miraklAccountingDocumentPaymentConfirmation + .setConfirmLinkedManualDocuments(paymentNotificationConfig.isConfirmLinkedManualDocuments()); log.info("Creating payment confirmation request for invoice ID {} and amount {}", miraklAccountingDocumentPaymentConfirmation.getInvoiceId(), diff --git a/hmc-invoices/src/test/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategyTest.java b/hmc-invoices/src/test/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategyTest.java index 1fa0aa1e..bca00030 100644 --- a/hmc-invoices/src/test/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategyTest.java +++ b/hmc-invoices/src/test/java/com/paypal/invoices/paymentnotifications/services/AcceptedPaymentNotificationStrategyTest.java @@ -77,6 +77,35 @@ void execute_shouldSendConfirmationPaymentToMirakl() { assertThat(accountingDocuments.get(0).getCurrencyIsoCode()).isEqualTo(MiraklIsoCurrencyCode.EUR); assertThat(accountingDocuments.get(0).getTransactionDate()).isEqualTo(DateUtil.convertToDate(CREATED_ON, HyperWalletConstants.HYPERWALLET_DATE_FORMAT, TimeZone.getTimeZone("UTC"))); + assertThat(accountingDocuments.get(0).isConfirmLinkedManualDocuments()).isFalse(); + } + + @Test + void execute_shouldSendConfirmationPaymentToMiraklConfirmingLinkedManualDocuments() { + when(paymentNotificationConfigMock.isConfirmLinkedManualDocuments()).thenReturn(true); + + when(paymentNotificationBodyModelMock.getAmount()).thenReturn(AMOUNT); + when(paymentNotificationBodyModelMock.getClientPaymentId()).thenReturn(INVOICE_ID); + when(paymentNotificationBodyModelMock.getCurrency()).thenReturn(CURRENCY_EUR_ISO_CODE); + when(paymentNotificationBodyModelMock.getCreatedOn()).thenReturn(CREATED_ON); + + testObj.execute(paymentNotificationBodyModelMock); + + verify(miraklClientMock).confirmAccountingDocumentPayment( + miraklConfirmAccountingDocumentPaymentRequestArgumentCaptor.capture()); + + final MiraklConfirmAccountingDocumentPaymentRequest miraklConfirmAccountingDocumentPaymentRequest = miraklConfirmAccountingDocumentPaymentRequestArgumentCaptor + .getValue(); + final List accountingDocuments = miraklConfirmAccountingDocumentPaymentRequest + .getAccountingDocuments(); + + assertThat(miraklConfirmAccountingDocumentPaymentRequest.getAccountingDocuments()).hasSize(1); + assertThat(accountingDocuments.get(0).getAmount()).isEqualTo(AMOUNT); + assertThat(accountingDocuments.get(0).getInvoiceId()).isEqualTo(Long.valueOf(INVOICE_ID)); + assertThat(accountingDocuments.get(0).getCurrencyIsoCode()).isEqualTo(MiraklIsoCurrencyCode.EUR); + assertThat(accountingDocuments.get(0).getTransactionDate()).isEqualTo(DateUtil.convertToDate(CREATED_ON, + HyperWalletConstants.HYPERWALLET_DATE_FORMAT, TimeZone.getTimeZone("UTC"))); + assertThat(accountingDocuments.get(0).isConfirmLinkedManualDocuments()).isTrue(); } @Test diff --git a/hmc-notifications/src/main/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImpl.java b/hmc-notifications/src/main/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImpl.java index 0ea6e566..200d0a45 100644 --- a/hmc-notifications/src/main/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImpl.java +++ b/hmc-notifications/src/main/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImpl.java @@ -23,9 +23,10 @@ public NotificationsRepositoryImpl(final UserHyperwalletSDKService userHyperwall } @Override - public HyperwalletWebhookNotification getHyperwalletWebhookNotification(final String program, final String token) { + public HyperwalletWebhookNotification getHyperwalletWebhookNotification(final String programToken, + final String token) { final Hyperwallet hyperwalletInstance = userHyperwalletSDKService - .getHyperwalletInstanceByHyperwalletProgram(program); + .getHyperwalletInstanceByProgramToken(programToken); try { return hyperwalletInstance.getWebhookEvent(token); } diff --git a/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImpl.java b/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImpl.java index 6f5ba976..e7961cef 100644 --- a/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImpl.java +++ b/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImpl.java @@ -38,10 +38,9 @@ public NotificationProcessingServiceImpl(final NotificationConverter notificatio public void processNotification(final HyperwalletWebhookNotification incomingNotificationDTO) { final NotificationEntity notificationEntity = notificationConverter.convert(incomingNotificationDTO); - notificationStorageService.saveNotification(notificationEntity); - if (notificationEntityEvaluator.isProcessable(notificationEntity)) { hyperwalletWebhookNotificationSenderStrategyExecutor.execute(incomingNotificationDTO); + notificationStorageService.saveNotification(notificationEntity); } } diff --git a/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicated.java b/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicated.java index b7c8a949..4bd844fb 100644 --- a/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicated.java +++ b/hmc-notifications/src/main/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicated.java @@ -28,8 +28,8 @@ public IsDuplicated(final NotificationStorageService notificationStorageService) @Override public boolean test(final NotificationEntity notificationEntity) { - final boolean isDuplicated = super.notificationStorageService - .getNotificationsByWebHookToken(notificationEntity.getWebHookToken()).size() > 1; + final boolean isDuplicated = !super.notificationStorageService + .getNotificationsByWebHookToken(notificationEntity.getWebHookToken()).isEmpty(); if (isDuplicated) { log.warn("Duplicated notification: [{}]", notificationEntity.getWebHookToken()); diff --git a/hmc-notifications/src/test/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImplTest.java b/hmc-notifications/src/test/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImplTest.java index 75b526c4..f9581d23 100644 --- a/hmc-notifications/src/test/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImplTest.java +++ b/hmc-notifications/src/test/java/com/paypal/notifications/failures/connectors/NotificationsRepositoryImplTest.java @@ -22,7 +22,7 @@ class NotificationsRepositoryImplTest { private static final String HYPERWALLET_NOTIFICATION_TOKEN = "TEST_TOKEN"; - private static final String HYPERWALLET_NOTIFICATION_PROGRAM = "TEST_PROGRAM"; + private static final String HYPERWALLET_NOTIFICATION_PROGRAM_TOKEN = "TEST_PROGRAM_TOKE"; private static final String MSG_ERROR = "An error has occurred"; @@ -44,38 +44,38 @@ class NotificationsRepositoryImplTest { @Test void getHyperwalletWebhookNotification_shouldReturnAnHyperwalletNotification_WhenTokenExists() { - when(userHyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_NOTIFICATION_PROGRAM)) + when(userHyperwalletSDKService.getHyperwalletInstanceByProgramToken(HYPERWALLET_NOTIFICATION_PROGRAM_TOKEN)) .thenReturn(hyperwalletInstanceMock); when(hyperwalletInstanceMock.getWebhookEvent(HYPERWALLET_NOTIFICATION_TOKEN)) .thenReturn(hyperwalletWebhookNotificationMock); - final HyperwalletWebhookNotification result = testObj - .getHyperwalletWebhookNotification(HYPERWALLET_NOTIFICATION_PROGRAM, HYPERWALLET_NOTIFICATION_TOKEN); + final HyperwalletWebhookNotification result = testObj.getHyperwalletWebhookNotification( + HYPERWALLET_NOTIFICATION_PROGRAM_TOKEN, HYPERWALLET_NOTIFICATION_TOKEN); assertThat(result).isEqualTo(hyperwalletWebhookNotificationMock); } @Test void getHyperwalletWebhookNotification_shouldReturnNull_WhenTokenNotExists() { - when(userHyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_NOTIFICATION_PROGRAM)) + when(userHyperwalletSDKService.getHyperwalletInstanceByProgramToken(HYPERWALLET_NOTIFICATION_PROGRAM_TOKEN)) .thenReturn(hyperwalletInstanceMock); when(hyperwalletInstanceMock.getWebhookEvent(HYPERWALLET_NOTIFICATION_TOKEN)).thenReturn(null); - final HyperwalletWebhookNotification result = testObj - .getHyperwalletWebhookNotification(HYPERWALLET_NOTIFICATION_PROGRAM, HYPERWALLET_NOTIFICATION_TOKEN); + final HyperwalletWebhookNotification result = testObj.getHyperwalletWebhookNotification( + HYPERWALLET_NOTIFICATION_PROGRAM_TOKEN, HYPERWALLET_NOTIFICATION_TOKEN); assertThat(result).isNull(); } @Test void getHyperwalletWebhookNotification_shouldReturnNull_andLogException_WhenExceptionIsThrown() { - when(userHyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_NOTIFICATION_PROGRAM)) + when(userHyperwalletSDKService.getHyperwalletInstanceByProgramToken(HYPERWALLET_NOTIFICATION_PROGRAM_TOKEN)) .thenReturn(hyperwalletInstanceMock); final HyperwalletException hyperwalletException = new HyperwalletException(MSG_ERROR); when(hyperwalletInstanceMock.getWebhookEvent(HYPERWALLET_NOTIFICATION_TOKEN)).thenThrow(hyperwalletException); - final HyperwalletWebhookNotification result = testObj - .getHyperwalletWebhookNotification(HYPERWALLET_NOTIFICATION_PROGRAM, HYPERWALLET_NOTIFICATION_TOKEN); + final HyperwalletWebhookNotification result = testObj.getHyperwalletWebhookNotification( + HYPERWALLET_NOTIFICATION_PROGRAM_TOKEN, HYPERWALLET_NOTIFICATION_TOKEN); assertThat(result).isNull(); assertThat(logTrackerStub.contains("Could not fetch notification [%s] due to reason:%n%s".formatted( diff --git a/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImplTest.java b/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImplTest.java index 9cb11aea..811a658d 100644 --- a/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImplTest.java +++ b/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/NotificationProcessingServiceImplTest.java @@ -49,12 +49,13 @@ void processNotification_shouldSaveAndProcessIncomingNotificationAndReturnsOK_Wh hyperwalletWebhookNotificationSenderStrategyExecutorMock); inOrder.verify(notificationConverterMock).convert(hyperwalletWebhookNotification1Mock); + inOrder.verify(hyperwalletWebhookNotificationSenderStrategyExecutorMock) + .execute(hyperwalletWebhookNotification1Mock); inOrder.verify(notificationStorageServiceMock).saveNotification(notificationEntityMock); - verify(hyperwalletWebhookNotificationSenderStrategyExecutorMock).execute(hyperwalletWebhookNotification1Mock); } @Test - void processNotification_shouldSaveAndNotProcessIncomingNotificationAndReturnsOK_WhenNotificationIsNotProcessable() { + void processNotification_shouldNotSaveAndNotProcessIncomingNotificationAndReturnsOK_WhenNotificationIsNotProcessable() { when(notificationEntityEvaluatorMock.isProcessable(notificationEntityMock)).thenReturn(false); when(notificationConverterMock.convert(hyperwalletWebhookNotification1Mock)).thenReturn(notificationEntityMock); @@ -64,9 +65,9 @@ void processNotification_shouldSaveAndNotProcessIncomingNotificationAndReturnsOK hyperwalletWebhookNotificationSenderStrategyExecutorMock); inOrder.verify(notificationConverterMock).convert(hyperwalletWebhookNotification1Mock); - inOrder.verify(notificationStorageServiceMock).saveNotification(notificationEntityMock); verify(hyperwalletWebhookNotificationSenderStrategyExecutorMock, never()) .execute(hyperwalletWebhookNotification1Mock); + verify(notificationStorageServiceMock, never()).saveNotification(notificationEntityMock); } } diff --git a/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicatedTest.java b/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicatedTest.java index 4b9807fe..3f0951fa 100644 --- a/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicatedTest.java +++ b/hmc-notifications/src/test/java/com/paypal/notifications/incoming/services/evaluators/predicates/IsDuplicatedTest.java @@ -45,14 +45,14 @@ void test_ShouldReturnFalse_WhenThereAreNotNotificationWithTheSameWebHookToken() } @Test - void test_ShouldReturnFalse_WhenThereIsOneNotificationWithTheSameWebHookToken() { + void test_ShouldReturnTrue_WhenThereIsOneNotificationWithTheSameWebHookToken() { when(notificationStorageService.getNotificationsByWebHookToken(WEB_HOOK_TOKEN)) .thenReturn(List.of(new NotificationEntity())); final boolean result = testObj.test(notificationEntityMock); - assertThat(result).isFalse(); + assertThat(result).isTrue(); } @Test diff --git a/hmc-observability/build.gradle b/hmc-observability/build.gradle index 7e25588b..eacf7e7d 100644 --- a/hmc-observability/build.gradle +++ b/hmc-observability/build.gradle @@ -9,7 +9,7 @@ dependencies { inpath 'org.apache.httpcomponents:httpclient' inpath 'com.hyperwallet:sdk:2.4.3' - inpath 'com.mirakl:mmp-sdk-operator:6.37.0' + inpath 'com.mirakl:mmp-sdk-operator:7.2.0' testImplementation project(":hmc-testsupport") } diff --git a/hmc-observability/src/main/java/com/paypal/observability/trafficauditor/adapters/mirakl/MiraklTrafficAuditorAdapter.java b/hmc-observability/src/main/java/com/paypal/observability/trafficauditor/adapters/mirakl/MiraklTrafficAuditorAdapter.java index 5a69ff30..34c1b910 100644 --- a/hmc-observability/src/main/java/com/paypal/observability/trafficauditor/adapters/mirakl/MiraklTrafficAuditorAdapter.java +++ b/hmc-observability/src/main/java/com/paypal/observability/trafficauditor/adapters/mirakl/MiraklTrafficAuditorAdapter.java @@ -100,7 +100,14 @@ private Map getQueryParameters(final HttpRequest request) { } private String getUrl(final HttpRequest request) { - return request.getRequestLine().getUri(); + String uri = request.getRequestLine().getUri(); + final Header host = Arrays.stream(request.getHeaders("Host")).findFirst().orElse(null); + + if (null != host && !host.getValue().isEmpty()) { + uri = "https://" + host.getValue() + uri; + } + + return uri; } @SneakyThrows diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategy.java b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategy.java index 7f491f9d..0d0fdcf9 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategy.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategy.java @@ -1,10 +1,10 @@ package com.paypal.sellers.bankaccountextraction.services.converters.mirakl; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklAbaBankAccountInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklPaymentInformation; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.strategy.Strategy; import com.paypal.sellers.bankaccountextraction.model.ABABankAccountModel; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; @@ -58,8 +58,9 @@ public ABABankAccountModel execute(@NonNull final MiraklShop source) { .transferType(hyperwalletBankAccountCurrencyInfo.getTransferType()) .type(BankAccountType.ABA) .bankAccountNumber(miraklAbaBankAccountInformation.getBankAccountNumber()) - .businessName(Optional.ofNullable(source.getProfessionalInformation()) - .map(MiraklProfessionalInformation::getCorporateName) + .businessName(Optional.ofNullable(source.getDefaultBillingInformation()) + .map(MiraklDefaultBillingInformation::getCorporateInformation) + .map(MiraklDefaultBillingInformation.CorporateInformation::getCompanyRegistrationName) .orElse(null)) .firstName(contactInformation.getFirstname()) .lastName(contactInformation.getLastname()) diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategy.java b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategy.java index 8e8f3811..187d15e5 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategy.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategy.java @@ -1,10 +1,10 @@ package com.paypal.sellers.bankaccountextraction.services.converters.mirakl; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklCanadianBankAccountInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklPaymentInformation; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.strategy.Strategy; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.bankaccountextraction.model.BankAccountType; @@ -55,8 +55,9 @@ public BankAccountModel execute(final MiraklShop source) { .transferType(hyperwalletBankAccountCurrencyInfo.getTransferType()) .type(BankAccountType.CANADIAN) .bankAccountNumber(miraklCanadianBankAccountInformation.getBankAccountNumber()) - .businessName(Optional.ofNullable(source.getProfessionalInformation()) - .map(MiraklProfessionalInformation::getCorporateName) + .businessName(Optional.ofNullable(source.getDefaultBillingInformation()) + .map(MiraklDefaultBillingInformation::getCorporateInformation) + .map(MiraklDefaultBillingInformation.CorporateInformation::getCompanyRegistrationName) .orElse(null)) .firstName(contactInformation.getFirstname()) .lastName(contactInformation.getLastname()) diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategy.java b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategy.java index 79e7ee46..85e68347 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategy.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategy.java @@ -1,10 +1,10 @@ package com.paypal.sellers.bankaccountextraction.services.converters.mirakl; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklIbanBankAccountInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklPaymentInformation; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.strategy.Strategy; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.bankaccountextraction.model.BankAccountType; @@ -57,8 +57,9 @@ public IBANBankAccountModel execute(@NonNull final MiraklShop source) { .type(BankAccountType.IBAN) .bankBic(miraklIbanBankAccountInformation.getBic()) .bankAccountNumber(miraklIbanBankAccountInformation.getIban()) - .businessName(Optional.ofNullable(source.getProfessionalInformation()) - .map(MiraklProfessionalInformation::getCorporateName) + .businessName(Optional.ofNullable(source.getDefaultBillingInformation()) + .map(MiraklDefaultBillingInformation::getCorporateInformation) + .map(MiraklDefaultBillingInformation.CorporateInformation::getCompanyRegistrationName) .orElse(null)) .firstName(contactInformation.getFirstname()) .lastName(contactInformation.getLastname()) diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategy.java b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategy.java index d445f069..4c73be4f 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategy.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategy.java @@ -1,10 +1,10 @@ package com.paypal.sellers.bankaccountextraction.services.converters.mirakl; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklPaymentInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklUkBankAccountInformation; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.strategy.Strategy; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.bankaccountextraction.model.BankAccountType; @@ -52,8 +52,9 @@ public BankAccountModel execute(final MiraklShop source) { .type(BankAccountType.UK) .bankAccountNumber(miraklUkBankAccountInformation.getBankAccountNumber()) .bankAccountId(miraklUkBankAccountInformation.getBankSortCode()) - .businessName(Optional.ofNullable(source.getProfessionalInformation()) - .map(MiraklProfessionalInformation::getCorporateName) + .businessName(Optional.ofNullable(source.getDefaultBillingInformation()) + .map(MiraklDefaultBillingInformation::getCorporateInformation) + .map(MiraklDefaultBillingInformation.CorporateInformation::getCompanyRegistrationName) .orElse(null)) .firstName(contactInformation.getFirstname()) .lastName(contactInformation.getLastname()) diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverter.java b/hmc-sellers/src/main/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverter.java index 55463601..a44a7749 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverter.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverter.java @@ -7,6 +7,7 @@ import com.paypal.sellers.sellerextractioncommons.services.converters.AbstractMiraklShopToSellerModelConverter; import com.paypal.sellers.sellerextractioncommons.model.SellerModel; import com.paypal.sellers.sellerextractioncommons.model.SellerProfileType; +import com.paypal.sellers.utils.LanguageConverter; import org.springframework.stereotype.Service; @Service @@ -14,8 +15,8 @@ public class MiraklShopToIndividualSellerModelConverter extends AbstractMiraklSh protected MiraklShopToIndividualSellerModelConverter( final StrategyExecutor miraklShopBankAccountModelStrategyExecutor, - final SellersMiraklApiConfig sellersMiraklApiConfig) { - super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig); + final SellersMiraklApiConfig sellersMiraklApiConfig, final LanguageConverter languageConversion) { + super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig, languageConversion); } /** diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverter.java b/hmc-sellers/src/main/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverter.java index 07abac41..5a8342b1 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverter.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverter.java @@ -2,20 +2,24 @@ import com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue; import com.mirakl.client.mmp.domain.shop.MiraklShop; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.converter.Converter; import com.paypal.infrastructure.support.strategy.StrategyExecutor; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.sellerextractioncommons.configuration.SellersMiraklApiConfig; -import com.paypal.sellers.sellerextractioncommons.services.converters.AbstractMiraklShopToSellerModelConverter; -import com.paypal.sellers.stakeholdersextraction.model.BusinessStakeHolderModel; import com.paypal.sellers.sellerextractioncommons.model.SellerModel; import com.paypal.sellers.sellerextractioncommons.model.SellerProfileType; +import com.paypal.sellers.sellerextractioncommons.services.converters.AbstractMiraklShopToSellerModelConverter; +import com.paypal.sellers.stakeholdersextraction.model.BusinessStakeHolderModel; +import com.paypal.sellers.utils.LanguageConverter; import org.apache.commons.lang3.tuple.Triple; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -28,11 +32,14 @@ public class MiraklShopToProfessionalSellerModelConverter extends AbstractMirakl private final Converter, Integer, String>, BusinessStakeHolderModel> pairBusinessStakeHolderModelConverter; + @Value("#{'${hmc.hyperwallet.countries.not.local.tax}'.split(',')}") + private List countriesNotLocalTax; + protected MiraklShopToProfessionalSellerModelConverter( final StrategyExecutor miraklShopBankAccountModelStrategyExecutor, final Converter, Integer, String>, BusinessStakeHolderModel> pairBusinessStakeHolderModelConverter, - final SellersMiraklApiConfig sellersMiraklApiConfig) { - super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig); + final SellersMiraklApiConfig sellersMiraklApiConfig, final LanguageConverter languageConversion) { + super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig, languageConversion); this.pairBusinessStakeHolderModelConverter = pairBusinessStakeHolderModelConverter; } @@ -51,14 +58,23 @@ public SellerModel execute(final MiraklShop source) { .filter(Predicate.not(BusinessStakeHolderModel::isEmpty)) .collect(Collectors.toCollection(ArrayList::new)); - final List additionalFieldValues = source.getAdditionalFieldValues(); + final MiraklDefaultBillingInformation.CorporateInformation corporateInformation = Optional.of(source) + .map(MiraklShop::getDefaultBillingInformation) + .map(MiraklDefaultBillingInformation::getCorporateInformation) + .orElse(null); + + final MiraklDefaultBillingInformation.FiscalInformation fiscalInformation = Optional.of(source) + .map(MiraklShop::getDefaultBillingInformation) + .map(MiraklDefaultBillingInformation::getFiscalInformation) + .orElse(null); + final List additionalFieldValues = source.getAdditionalFieldValues(); return sellerModelBuilder.profileType(SellerProfileType.BUSINESS) .companyRegistrationCountry(additionalFieldValues) .businessRegistrationStateProvince(additionalFieldValues) - .companyName(source.getProfessionalInformation().getCorporateName()) - .companyRegistrationNumber(source.getProfessionalInformation().getIdentificationNumber()) - .vatNumber(source.getProfessionalInformation().getTaxIdentificationNumber()) + .companyName(corporateInformation != null ? corporateInformation.getCompanyRegistrationName() : null) + .companyRegistrationNumber(corporateInformation != null ? corporateInformation.getCompanyRegistrationNumber() : null) + .vatNumber(fiscalInformation != null ? getTaxNumber(fiscalInformation) : null) .businessStakeHolderDetails(businessStakeHolderList) .build(); //@formatter:on @@ -69,4 +85,23 @@ public boolean isApplicable(final MiraklShop source) { return source.isProfessional(); } + /** + * Method that retrieves the tax number based on the country + * @param fiscalInformation the fiscal information + * @return the tax number + */ + protected String getTaxNumber(final MiraklDefaultBillingInformation.FiscalInformation fiscalInformation) { + if (fiscalInformation.getTaxIdentificationCountry() == null + || fiscalInformation.getTaxIdentificationCountry().isBlank()) { + return fiscalInformation.getLocalTaxNumber(); + } + else if (countriesNotLocalTax.contains(fiscalInformation.getTaxIdentificationCountry())) { + return fiscalInformation.getTaxIdentificationNumber(); + } + else { + return fiscalInformation.getLocalTaxNumber(); + } + + } + } diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToSellerModelConverter.java b/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToSellerModelConverter.java index 1b20895b..fc7f6d24 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToSellerModelConverter.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToSellerModelConverter.java @@ -3,11 +3,13 @@ import com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.strategy.Strategy; import com.paypal.infrastructure.support.strategy.StrategyExecutor; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.sellerextractioncommons.configuration.SellersMiraklApiConfig; import com.paypal.sellers.sellerextractioncommons.model.SellerModel; +import com.paypal.sellers.utils.LanguageConverter; import java.util.List; @@ -17,19 +19,25 @@ public abstract class AbstractMiraklShopToSellerModelConverter implements Strate private final SellersMiraklApiConfig sellersMiraklApiConfig; + private final LanguageConverter languageConversion; + protected AbstractMiraklShopToSellerModelConverter( final StrategyExecutor miraklShopBankAccountModelStrategyExecutor, - final SellersMiraklApiConfig sellersMiraklApiConfig) { + final SellersMiraklApiConfig sellersMiraklApiConfig, final LanguageConverter languageConversion) { this.miraklShopBankAccountModelStrategyExecutor = miraklShopBankAccountModelStrategyExecutor; this.sellersMiraklApiConfig = sellersMiraklApiConfig; + this.languageConversion = languageConversion; } protected SellerModel.SellerModelBuilder getCommonFieldsBuilder(final MiraklShop source) { final MiraklContactInformation contactInformation = source.getContactInformation(); final List additionalFieldValues = source.getAdditionalFieldValues(); final BankAccountModel bankAccountModel = miraklShopBankAccountModelStrategyExecutor.execute(source); + final MiraklDefaultBillingInformation defaultBillingInformation = source.getDefaultBillingInformation(); + final String language = languageConversion.convert(defaultBillingInformation.getDefaultLanguage()); //@formatter:off return SellerModel.builder() + .language(language) .clientUserId(source.getId()) .businessName(source.getName()) .firstName(contactInformation.getFirstname()) diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverter.java b/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverter.java index 5aaf096f..1cc4d3f7 100644 --- a/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverter.java +++ b/hmc-sellers/src/main/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverter.java @@ -47,6 +47,7 @@ public HyperwalletUser convert(final SellerModel sellerModel) { .getProgramConfiguration(sellerModel.getHyperwalletProgram()).getUsersProgramToken()); hyperwalletUser.setToken(sellerModel.getToken()); hyperwalletUser.setEmail(sellerModel.getEmail()); + hyperwalletUser.setLanguage(sellerModel.getLanguage()); if (HyperwalletUser.ProfileType.BUSINESS.equals(profileType)) { hyperwalletUser.setBusinessRegistrationCountry(sellerModel.getCompanyRegistrationCountry()); diff --git a/hmc-sellers/src/main/java/com/paypal/sellers/utils/LanguageConverter.java b/hmc-sellers/src/main/java/com/paypal/sellers/utils/LanguageConverter.java new file mode 100644 index 00000000..b6e173f8 --- /dev/null +++ b/hmc-sellers/src/main/java/com/paypal/sellers/utils/LanguageConverter.java @@ -0,0 +1,47 @@ +package com.paypal.sellers.utils; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Locale; + +@Component +public final class LanguageConverter { + + private static final String CHINA_SIMPLIFIED = "zh_CN"; + + @Value("#{'${hmc.hyperwallet.supported.languages}'.split(',')}") + private List supportedLanguages; + + @Value("#{'${hmc.hyperwallet.default.language}'}") + private String defaultLanguage; + + protected LanguageConverter() { + } + + /** + * Hyperwallet require that the language code be in ISO-639-1 format. + * @param input - the input string of locale (e.g. en_GB) + * @return the 2 digit language tag + * @see Supported + * Languages + */ + public String convert(final Locale input) { + return input != null ? getLanguage(input) : null; + } + + private String getLanguage(final Locale input) { + if (input.equals(Locale.CHINA)) { + return CHINA_SIMPLIFIED; + } + else if (supportedLanguages.contains(input.getLanguage())) { + return input.getLanguage(); + } + else { + return defaultLanguage; + } + } + +} diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategyTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategyTest.java index 4a9043ce..af1096f3 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategyTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToABABankAccountModelConverterStrategyTest.java @@ -3,10 +3,10 @@ import com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue; import com.mirakl.client.mmp.domain.common.currency.MiraklIsoCurrencyCode; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklAbaBankAccountInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklIbanBankAccountInformation; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.sellers.bankaccountextraction.model.ABABankAccountModel; import com.paypal.sellers.bankaccountextraction.model.BankAccountType; import com.paypal.sellers.bankaccountextraction.model.TransferType; @@ -76,7 +76,10 @@ class MiraklShopToABABankAccountModelConverterStrategyTest { private MiraklAbaBankAccountInformation miraklABABankAccountInformationMock; @Mock - private MiraklProfessionalInformation miraklProfessionalInformationMock; + private MiraklDefaultBillingInformation miraklDefaultBillingInformationMock; + + @Mock + private MiraklDefaultBillingInformation.CorporateInformation miraklCorporateInformationMock; @Mock private MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue miraklBankAccountTokenFieldValueMock, @@ -93,7 +96,8 @@ void execute_ShouldTransformFromMiraklShopToABAAccountModel() { when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklABABankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.USD); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()).thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklBankAccountStateFieldValueMock, miraklHyperwalletProgramFieldValueMock)); when(miraklBankAccountTokenFieldValueMock.getCode()).thenReturn(HYPERWALLET_BANK_ACCOUNT_TOKEN); @@ -113,7 +117,7 @@ void execute_ShouldTransformFromMiraklShopToABAAccountModel() { when(miraklABABankAccountInformationMock.getBankAccountNumber()).thenReturn(ABA_ACCOUNT); when(miraklABABankAccountInformationMock.getBankCity()).thenReturn(CITY_NAME); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( USA_COUNTRY_ISO, USD_CURRENCY, TransferType.BANK_ACCOUNT); @@ -147,7 +151,8 @@ void execute_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklABABankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.USD); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()).thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklBankAccountStateFieldValueMock, miraklHyperwalletProgramFieldValueMock)); when(miraklBankAccountTokenFieldValueMock.getCode()).thenReturn(HYPERWALLET_BANK_ACCOUNT_TOKEN); @@ -167,7 +172,7 @@ void execute_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklABABankAccountInformationMock.getBankAccountNumber()).thenReturn(ABA_ACCOUNT); when(miraklABABankAccountInformationMock.getBankCity()).thenReturn(CITY_NAME); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( USA_COUNTRY_ISO, USD_CURRENCY, TransferType.BANK_ACCOUNT); when(hyperwalletBankAccountCurrencyResolverMock.getCurrencyForCountry(BankAccountType.ABA.name(), diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategyTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategyTest.java index 7718d09b..ba15adb6 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategyTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToCanadianBankAccountModelConverterStrategyTest.java @@ -3,10 +3,10 @@ import com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue; import com.mirakl.client.mmp.domain.common.currency.MiraklIsoCurrencyCode; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklCanadianBankAccountInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklIbanBankAccountInformation; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.bankaccountextraction.model.BankAccountType; import com.paypal.sellers.bankaccountextraction.model.TransferType; @@ -78,7 +78,10 @@ class MiraklShopToCanadianBankAccountModelConverterStrategyTest { private MiraklCanadianBankAccountInformation miraklCanadianBankAccountInformationMock; @Mock - private MiraklProfessionalInformation miraklProfessionalInformationMock; + private MiraklDefaultBillingInformation miraklDefaultBillingInformationMock; + + @Mock + private MiraklDefaultBillingInformation.CorporateInformation miraklCorporateInformationMock; @Mock private MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue miraklBankAccountTokenFieldValueMock, @@ -95,7 +98,8 @@ void execute_ShouldTransformFromMiraklShopToCanadianAccountModel() { when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklCanadianBankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.USD); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()) .thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklBankAccountStateFieldValueMock, miraklBankAccountStateFieldValueMock, miraklHyperwalletProgramFieldValueMock)); @@ -117,7 +121,7 @@ void execute_ShouldTransformFromMiraklShopToCanadianAccountModel() { when(miraklCanadianBankAccountInformationMock.getBankCity()).thenReturn(CITY_NAME); when(miraklCanadianBankAccountInformationMock.getBankAccountNumber()).thenReturn(BANK_ACCOUNT_NUMBER); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( CA_COUNTRY_ISO, USD_CURRENCY, TransferType.BANK_ACCOUNT); @@ -152,7 +156,8 @@ void execute_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklCanadianBankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.USD); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()) .thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklBankAccountStateFieldValueMock, miraklBankAccountStateFieldValueMock, miraklHyperwalletProgramFieldValueMock)); @@ -174,7 +179,7 @@ void execute_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklCanadianBankAccountInformationMock.getBankCity()).thenReturn(CITY_NAME); when(miraklCanadianBankAccountInformationMock.getBankAccountNumber()).thenReturn(BANK_ACCOUNT_NUMBER); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( CA_COUNTRY_ISO, USD_CURRENCY, TransferType.BANK_ACCOUNT); diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategyTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategyTest.java index edfdfb34..c3f01797 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategyTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToIBANBankAccountModelConverterStrategyTest.java @@ -2,6 +2,7 @@ import java.util.List; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.sellers.bankaccountextraction.services.converters.currency.HyperwalletBankAccountCurrencyInfo; import com.paypal.sellers.bankaccountextraction.services.converters.currency.HyperwalletBankAccountCurrencyResolver; import org.apache.commons.lang3.StringUtils; @@ -15,7 +16,6 @@ import com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue; import com.mirakl.client.mmp.domain.common.currency.MiraklIsoCurrencyCode; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklAbaBankAccountInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklIbanBankAccountInformation; @@ -80,7 +80,10 @@ class MiraklShopToIBANBankAccountModelConverterStrategyTest { private MiraklIbanBankAccountInformation miraklIbanBankAccountInformationMock; @Mock - private MiraklProfessionalInformation miraklProfessionalInformationMock; + private MiraklDefaultBillingInformation miraklDefaultBillingInformationMock; + + @Mock + private MiraklDefaultBillingInformation.CorporateInformation miraklCorporateInformationMock; @Mock private MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue miraklBankAccountTokenFieldValueMock, @@ -97,7 +100,8 @@ void convert_ShouldTransformFromMiraklShopToIbanBankAccountModel() { when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklIbanBankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.EUR); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()).thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklBankAccountStateFieldValueMock, miraklHyperwalletProgramFieldValueMock)); when(miraklBankAccountTokenFieldValueMock.getCode()).thenReturn(HYPERWALLET_BANK_ACCOUNT_TOKEN); @@ -117,7 +121,8 @@ void convert_ShouldTransformFromMiraklShopToIbanBankAccountModel() { when(miraklIbanBankAccountInformationMock.getBic()).thenReturn(BIC_CODE); when(miraklIbanBankAccountInformationMock.getIban()).thenReturn(ES_IBAN_ACCOUNT); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( ES_COUNTRY_ISO, EUR_CURRENCY, TransferType.BANK_ACCOUNT); @@ -152,7 +157,8 @@ void convert_ShouldTransformFromMiraklShopToUKIbanBankAccountModel() { when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklIbanBankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.GBP); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()).thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklBankAccountStateFieldValueMock, miraklHyperwalletProgramFieldValueMock)); when(miraklBankAccountTokenFieldValueMock.getCode()).thenReturn(HYPERWALLET_BANK_ACCOUNT_TOKEN); @@ -172,7 +178,7 @@ void convert_ShouldTransformFromMiraklShopToUKIbanBankAccountModel() { when(miraklIbanBankAccountInformationMock.getIban()).thenReturn(UK_IBAN_ACCOUNT); when(miraklIbanBankAccountInformationMock.getBic()).thenReturn(BIC_CODE); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( UK_COUNTRY_ISO, MiraklIsoCurrencyCode.GBP.name(), TransferType.BANK_ACCOUNT); @@ -204,7 +210,8 @@ void convert_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklIbanBankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.EUR); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()) .thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklHyperwalletProgramFieldValueMock)); when(miraklBankAccountTokenFieldValueMock.getCode()).thenReturn(HYPERWALLET_BANK_ACCOUNT_TOKEN); @@ -222,7 +229,7 @@ void convert_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklIbanBankAccountInformationMock.getIban()).thenReturn(ES_IBAN_ACCOUNT); when(miraklIbanBankAccountInformationMock.getBankCity()).thenReturn(CITY_NAME); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( ES_COUNTRY_ISO, EUR_CURRENCY, TransferType.BANK_ACCOUNT); @@ -294,12 +301,6 @@ private MiraklIbanBankAccountInformation defaultMiraklIbanBankAccount() { return ibanAccountInfo; } - private MiraklProfessionalInformation defaultProfessionalInformation() { - final MiraklProfessionalInformation professionalInformation = new MiraklProfessionalInformation(); - professionalInformation.setCorporateName(BUSINESS_NAME); - return professionalInformation; - } - @Test void isApplicable_shouldReturnTrue_whenPaymentInformationIsIBAN() { when(miraklShopMock.getPaymentInformation()).thenReturn(miraklIbanBankAccountInformationMock); diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategyTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategyTest.java index f97b81ae..2fcd2ded 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategyTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/bankaccountextraction/services/converters/mirakl/MiraklShopToUKBankAccountModelConverterStrategyTest.java @@ -3,10 +3,10 @@ import com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue; import com.mirakl.client.mmp.domain.common.currency.MiraklIsoCurrencyCode; import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.mirakl.client.mmp.domain.shop.bank.MiraklAbaBankAccountInformation; import com.mirakl.client.mmp.domain.shop.bank.MiraklUkBankAccountInformation; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.bankaccountextraction.model.BankAccountType; import com.paypal.sellers.bankaccountextraction.model.TransferType; @@ -76,7 +76,10 @@ class MiraklShopToUKBankAccountModelConverterStrategyTest { private MiraklUkBankAccountInformation miraklUKBankAccountInformationMock; @Mock - private MiraklProfessionalInformation miraklProfessionalInformationMock; + private MiraklDefaultBillingInformation miraklDefaultBillingInformationMock; + + @Mock + private MiraklDefaultBillingInformation.CorporateInformation miraklCorporateInformationMock; @Mock private MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue miraklBankAccountTokenFieldValueMock, @@ -93,7 +96,8 @@ void convert_ShouldTransformFromMiraklShopToUkBankAccountModel() { when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklUKBankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.GBP); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()).thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklBankAccountStateFieldValueMock, miraklHyperwalletProgramFieldValueMock)); when(miraklBankAccountTokenFieldValueMock.getCode()).thenReturn(HYPERWALLET_BANK_ACCOUNT_TOKEN); @@ -113,7 +117,7 @@ void convert_ShouldTransformFromMiraklShopToUkBankAccountModel() { when(miraklUKBankAccountInformationMock.getBankAccountNumber()).thenReturn(BANK_ACCOUNT_NUMBER); when(miraklUKBankAccountInformationMock.getBankSortCode()).thenReturn(SORT_CODE); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( UK_COUNTRY_ISO, GBP_CURRENCY, TransferType.BANK_ACCOUNT); @@ -146,7 +150,8 @@ void convert_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); when(miraklShopMock.getPaymentInformation()).thenReturn(miraklUKBankAccountInformationMock); when(miraklShopMock.getCurrencyIsoCode()).thenReturn(MiraklIsoCurrencyCode.GBP); - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); when(miraklShopMock.getAdditionalFieldValues()) .thenReturn(List.of(miraklBankAccountTokenFieldValueMock, miraklHyperwalletProgramFieldValueMock)); when(miraklBankAccountTokenFieldValueMock.getCode()).thenReturn(HYPERWALLET_BANK_ACCOUNT_TOKEN); @@ -164,7 +169,7 @@ void convert_shouldEnsureThatOptionalFieldLineAddress2IsFilledWithAnEmptyString( when(miraklUKBankAccountInformationMock.getBankAccountNumber()).thenReturn(BANK_ACCOUNT_NUMBER); when(miraklUKBankAccountInformationMock.getBankCity()).thenReturn(CITY_NAME); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(BUSINESS_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(BUSINESS_NAME); final HyperwalletBankAccountCurrencyInfo hyperwalletBankAccountCurrencyInfo = new HyperwalletBankAccountCurrencyInfo( UK_COUNTRY_ISO, GBP_CURRENCY, TransferType.BANK_ACCOUNT); diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverterTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverterTest.java index 369ea205..7520bd0f 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverterTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/individualsellersextraction/services/converters/MiraklShopToIndividualSellerModelConverterTest.java @@ -3,10 +3,10 @@ import com.mirakl.client.mmp.domain.shop.MiraklShop; import com.paypal.infrastructure.support.strategy.StrategyExecutor; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; -import com.paypal.sellers.individualsellersextraction.services.converters.MiraklShopToIndividualSellerModelConverter; import com.paypal.sellers.sellerextractioncommons.configuration.SellersMiraklApiConfig; import com.paypal.sellers.sellerextractioncommons.model.SellerModel; import com.paypal.sellers.sellerextractioncommons.model.SellerProfileType; +import com.paypal.sellers.utils.LanguageConverter; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -60,8 +60,8 @@ static class MyMiraklShopToIndividualSellerModelConverter extends MiraklShopToIn protected MyMiraklShopToIndividualSellerModelConverter( final StrategyExecutor miraklShopBankAccountModelStrategyExecutor, - final SellersMiraklApiConfig sellersMiraklApiConfig) { - super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig); + final SellersMiraklApiConfig sellersMiraklApiConfig, final LanguageConverter languageConversion) { + super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig, languageConversion); } @Override diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverterTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverterTest.java index 37747786..9eaf2784 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverterTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/professionalsellersextraction/services/converters/MiraklShopToProfessionalSellerModelConverterTest.java @@ -1,8 +1,8 @@ package com.paypal.sellers.professionalsellersextraction.services.converters; import com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue; -import com.mirakl.client.mmp.domain.shop.MiraklProfessionalInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.converter.Converter; import com.paypal.infrastructure.support.strategy.StrategyExecutor; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; @@ -10,13 +10,18 @@ import com.paypal.sellers.sellerextractioncommons.model.SellerModel; import com.paypal.sellers.sellerextractioncommons.model.SellerProfileType; import com.paypal.sellers.stakeholdersextraction.model.BusinessStakeHolderModel; +import com.paypal.sellers.utils.LanguageConverter; import org.apache.commons.lang3.tuple.Triple; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; import java.util.List; @@ -37,6 +42,10 @@ class MiraklShopToProfessionalSellerModelConverterTest { private static final String STATE_PROVINCE_VALUE = "stateProvince"; + private static final String COUNTRIES_NOT_LOCAL_TAX = "countriesNotLocalTax"; + + private static final String LOCAL_VAT_NUMBER = "localTaxNumber"; + @Spy @InjectMocks private MyMiraklShopToProfessionalSellerModelConverter testObj; @@ -48,7 +57,13 @@ class MiraklShopToProfessionalSellerModelConverterTest { private Converter, Integer, String>, BusinessStakeHolderModel> businessStakeHolderModelConverterMock; @Mock - private MiraklProfessionalInformation miraklProfessionalInformationMock; + private MiraklDefaultBillingInformation miraklDefaultBillingInformationMock; + + @Mock + private MiraklDefaultBillingInformation.CorporateInformation miraklCorporateInformationMock; + + @Mock + private MiraklDefaultBillingInformation.FiscalInformation miraklFiscalInformationMock; @Mock private MiraklAdditionalFieldValue tokenOneAdditionalFieldMock, businessOneAdditionalFieldMock, @@ -77,12 +92,20 @@ class MiraklShopToProfessionalSellerModelConverterTest { @Mock private BusinessStakeHolderModel businessStakeHolderModelOneMock, businessStakeHolderModelTwoMock; + @BeforeEach + void setUp() { + final List countriesNotLocalTax = List.of("KOR", "USA"); + ReflectionTestUtils.setField(testObj, COUNTRIES_NOT_LOCAL_TAX, countriesNotLocalTax); + } + @Test void execute_shouldSetProfileTypeToIndividual() { - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(CORP_NAME); - when(miraklProfessionalInformationMock.getIdentificationNumber()).thenReturn(IDENTIFICATION_NUMBER); - when(miraklProfessionalInformationMock.getTaxIdentificationNumber()).thenReturn(VAT_NUMBER); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); + when(miraklDefaultBillingInformationMock.getFiscalInformation()).thenReturn(miraklFiscalInformationMock); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(CORP_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationNumber()).thenReturn(IDENTIFICATION_NUMBER); + when(miraklFiscalInformationMock.getLocalTaxNumber()).thenReturn(VAT_NUMBER); final MiraklStringAdditionalFieldValue businessRegistrationStateProvinceMiraklCustomField = new MiraklStringAdditionalFieldValue(); businessRegistrationStateProvinceMiraklCustomField.setCode("hw-business-reg-state-province"); @@ -110,11 +133,13 @@ void execute_shouldSetProfileTypeToIndividual() { @Test void execute_shouldConvertMiraklBusinessStakeHolderAttributesIntoListOfBusinessStakeHolderModel() { - when(miraklShopMock.getProfessionalInformation()).thenReturn(miraklProfessionalInformationMock); - when(miraklProfessionalInformationMock.getCorporateName()).thenReturn(CORP_NAME); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getCorporateInformation()).thenReturn(miraklCorporateInformationMock); + when(miraklDefaultBillingInformationMock.getFiscalInformation()).thenReturn(miraklFiscalInformationMock); when(miraklShopMock.getId()).thenReturn(CLIENT_ID_1); - when(miraklProfessionalInformationMock.getIdentificationNumber()).thenReturn(IDENTIFICATION_NUMBER); - when(miraklProfessionalInformationMock.getTaxIdentificationNumber()).thenReturn(VAT_NUMBER); + when(miraklCorporateInformationMock.getCompanyRegistrationName()).thenReturn(CORP_NAME); + when(miraklCorporateInformationMock.getCompanyRegistrationNumber()).thenReturn(IDENTIFICATION_NUMBER); + when(miraklFiscalInformationMock.getLocalTaxNumber()).thenReturn(VAT_NUMBER); final List additionalFieldValues = List.of(tokenOneAdditionalFieldMock, businessOneAdditionalFieldMock, directorOneAdditionalFieldMock, uboOneAdditionalFieldMock, @@ -180,14 +205,43 @@ void isApplicable_shouldReturnFalseWhenMiraklShopIsNotProfessional() { assertThat(result).isFalse(); } + @ParameterizedTest + @ValueSource(strings = { "", " ", "ESP", "FRA" }) + void getTaxNumber_shouldReturnLocalTaxNumberWhenTaxIdentificationCountryIsBlankOrNotMatch(final String country) { + when(miraklFiscalInformationMock.getLocalTaxNumber()).thenReturn(LOCAL_VAT_NUMBER); + when(miraklFiscalInformationMock.getTaxIdentificationCountry()).thenReturn(country); + + final String result = testObj.getTaxNumber(miraklFiscalInformationMock); + assertThat(result).isEqualTo(LOCAL_VAT_NUMBER); + } + + @Test + void getTaxNumber_shouldReturnLocalTaxNumberWhenTaxIdentificationCountryIsNull() { + when(miraklFiscalInformationMock.getLocalTaxNumber()).thenReturn(LOCAL_VAT_NUMBER); + when(miraklFiscalInformationMock.getTaxIdentificationCountry()).thenReturn(null); + + final String result = testObj.getTaxNumber(miraklFiscalInformationMock); + assertThat(result).isEqualTo(LOCAL_VAT_NUMBER); + } + + @ParameterizedTest + @ValueSource(strings = { "USA", "KOR" }) + void getTaxNumber_shouldReturnTaxIdentificationNumberWhenTaxIdentificationCountryMatch(final String country) { + when(miraklFiscalInformationMock.getTaxIdentificationNumber()).thenReturn(VAT_NUMBER); + when(miraklFiscalInformationMock.getTaxIdentificationCountry()).thenReturn(country); + + final String result = testObj.getTaxNumber(miraklFiscalInformationMock); + assertThat(result).isEqualTo(VAT_NUMBER); + } + static class MyMiraklShopToProfessionalSellerModelConverter extends MiraklShopToProfessionalSellerModelConverter { protected MyMiraklShopToProfessionalSellerModelConverter( final StrategyExecutor miraklShopBankAccountModelStrategyExecutor, final Converter, Integer, String>, BusinessStakeHolderModel> pairBusinessStakeHolderModelConverter, - final SellersMiraklApiConfig sellersMiraklApiConfig) { + final SellersMiraklApiConfig sellersMiraklApiConfig, final LanguageConverter languageConversion) { super(miraklShopBankAccountModelStrategyExecutor, pairBusinessStakeHolderModelConverter, - sellersMiraklApiConfig); + sellersMiraklApiConfig, languageConversion); } @Override diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToIndividualSellerModelConverterTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToIndividualSellerModelConverterTest.java index bad80e9c..a825d0bf 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToIndividualSellerModelConverterTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/AbstractMiraklShopToIndividualSellerModelConverterTest.java @@ -2,13 +2,14 @@ import com.mirakl.client.mmp.domain.shop.MiraklContactInformation; import com.mirakl.client.mmp.domain.shop.MiraklShop; +import com.mirakl.client.mmp.domain.shop.billing.MiraklDefaultBillingInformation; import com.paypal.infrastructure.support.strategy.StrategyExecutor; import com.paypal.sellers.bankaccountextraction.model.BankAccountModel; import com.paypal.sellers.bankaccountextraction.model.IBANBankAccountModel; import com.paypal.sellers.sellerextractioncommons.configuration.SellersMiraklApiConfig; import com.paypal.sellers.sellerextractioncommons.model.SellerModel; import com.paypal.sellers.sellerextractioncommons.model.SellerModel.SellerModelBuilder; -import com.paypal.sellers.sellerextractioncommons.services.converters.AbstractMiraklShopToSellerModelConverter; +import com.paypal.sellers.utils.LanguageConverter; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -16,6 +17,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.util.Collections; +import java.util.Locale; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; @@ -41,12 +43,20 @@ class AbstractMiraklShopToIndividualSellerModelConverterTest { @Mock private IBANBankAccountModel IBANBankAccountModelMock; + @Mock + private MiraklDefaultBillingInformation miraklDefaultBillingInformationMock; + + @Mock + private LanguageConverter languageConversionMock; + @Test void convert_ShouldTransformFromMiraklShopToProfessionalSeller() { when(sellersMiraklApiConfigMock.getTimeZone()).thenReturn("UTC"); when(miraklShopMock.getId()).thenReturn("shopId"); when(miraklShopMock.getName()).thenReturn("shopName"); when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getDefaultLanguage()).thenReturn(Locale.US); when(contactInformationMock.getFirstname()).thenReturn("firstName"); when(contactInformationMock.getLastname()).thenReturn("lastName"); when(contactInformationMock.getPhone()).thenReturn("phone"); @@ -63,6 +73,7 @@ void convert_ShouldTransformFromMiraklShopToProfessionalSeller() { when(miraklShopMock.getAdditionalFieldValues()).thenReturn(Collections.emptyList()); when(miraklShopBankAccountModelStrategyExecutor.execute(miraklShopMock)).thenReturn(IBANBankAccountModelMock); + when(languageConversionMock.convert(Locale.US)).thenReturn("en"); final SellerModelBuilder result = testObj.getCommonFieldsBuilder(miraklShopMock); @@ -80,7 +91,8 @@ void convert_ShouldTransformFromMiraklShopToProfessionalSeller() { .hasFieldOrPropertyWithValue("postalCode", "zipcode") .hasFieldOrPropertyWithValue("stateProvince", "state") .hasFieldOrPropertyWithValue("country", "US") - .hasFieldOrPropertyWithValue("bankAccountDetails", IBANBankAccountModelMock); + .hasFieldOrPropertyWithValue("bankAccountDetails", IBANBankAccountModelMock) + .hasFieldOrPropertyWithValue("language", "en"); //@formatter:on } @@ -90,6 +102,8 @@ void convert_ShouldTransformFromMiraklShopToProfessionalSellerWhenBankAccountDet when(miraklShopMock.getId()).thenReturn("shopId"); when(miraklShopMock.getName()).thenReturn("shopName"); when(miraklShopMock.getContactInformation()).thenReturn(contactInformationMock); + when(miraklShopMock.getDefaultBillingInformation()).thenReturn(miraklDefaultBillingInformationMock); + when(miraklDefaultBillingInformationMock.getDefaultLanguage()).thenReturn(Locale.US); when(contactInformationMock.getFirstname()).thenReturn("firstName"); when(contactInformationMock.getLastname()).thenReturn("lastName"); when(contactInformationMock.getPhone()).thenReturn("phone"); @@ -104,6 +118,7 @@ void convert_ShouldTransformFromMiraklShopToProfessionalSellerWhenBankAccountDet // Not testing the builder part where it is converting and setting values from // mirakl custom fields when(miraklShopMock.getAdditionalFieldValues()).thenReturn(Collections.emptyList()); + when(languageConversionMock.convert(Locale.US)).thenReturn("en"); final SellerModelBuilder result = testObj.getCommonFieldsBuilder(miraklShopMock); //@formatter:off @@ -120,7 +135,8 @@ void convert_ShouldTransformFromMiraklShopToProfessionalSellerWhenBankAccountDet .hasFieldOrPropertyWithValue("postalCode", "zipcode") .hasFieldOrPropertyWithValue("stateProvince", "state") .hasFieldOrPropertyWithValue("country", "US") - .hasFieldOrPropertyWithValue("bankAccountDetails", null); + .hasFieldOrPropertyWithValue("bankAccountDetails", null) + .hasFieldOrPropertyWithValue("language", "en"); //@formatter:on } @@ -128,8 +144,8 @@ private static class MyAbstractMiraklShopToSellerModelConverter extends Abstract protected MyAbstractMiraklShopToSellerModelConverter( final StrategyExecutor miraklShopBankAccountModelStrategyExecutor, - final SellersMiraklApiConfig sellersMiraklApiConfig) { - super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig); + final SellersMiraklApiConfig sellersMiraklApiConfig, final LanguageConverter languageConversion) { + super(miraklShopBankAccountModelStrategyExecutor, sellersMiraklApiConfig, languageConversion); } @Override diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverterTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverterTest.java index 0a11bb53..f81a7191 100644 --- a/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverterTest.java +++ b/hmc-sellers/src/test/java/com/paypal/sellers/sellerextractioncommons/services/converters/SellerModelToHyperWalletUserConverterTest.java @@ -80,6 +80,8 @@ class SellerModelToHyperWalletUserConverterTest { private static final String NEW_USER_MAPPING_ENABLED = "newUserMappingEnabled"; + private static final String LANGUAGE = "en"; + @InjectMocks private SellerModelToHyperWalletUserConverter testObj; @@ -126,6 +128,7 @@ void setUp() { lenient().when(sellerModelMock.getPassportId()).thenReturn(PASSPORT_ID); lenient().when(sellerModelMock.getMobilePhone()).thenReturn(MOBILE_PHONE); lenient().when(sellerModelMock.getCompanyName()).thenReturn(COMPANY_NAME); + lenient().when(sellerModelMock.getLanguage()).thenReturn(LANGUAGE); } @Test @@ -137,7 +140,7 @@ void convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheProfessionalSeller assertThat(result).hasAllNullFieldsOrPropertiesExcept("clientUserId", "businessName", "profileType", "businessType", "addressLine1", "city", "stateProvince", "postalCode", "programToken", "country", "token", "inclusions", "email", "businessRegistrationCountry", "businessRegistrationStateProvince", - "businessRegistrationId", "businessOperatingName"); + "businessRegistrationId", "businessOperatingName", "language"); assertThat(result.getClientUserId()).isEqualTo(CLIENT_USER_ID); assertThat(result.getBusinessName()).isEqualTo(BUSINESS_NAME); assertThat(result.getBusinessOperatingName()).isEqualTo(COMPANY_NAME); @@ -154,6 +157,7 @@ void convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheProfessionalSeller assertThat(result.getBusinessRegistrationCountry()).isEqualTo(COMPANY_REGISTRATION_COUNTRY); assertThat(result.getBusinessRegistrationStateProvince()).isEqualTo(BUSINESS_REGISTRATION_STATE_PROVINCE); assertThat(result.getBusinessRegistrationId()).isEqualTo(COMPANY_REGISTRATION_NUMBER); + assertThat(result.getLanguage()).isEqualTo(LANGUAGE); } @Test @@ -167,7 +171,7 @@ void convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheProfessionalSeller assertThat(result).hasAllNullFieldsOrPropertiesExcept("clientUserId", "businessName", "profileType", "businessType", "addressLine1", "city", "stateProvince", "postalCode", "programToken", "country", "token", "inclusions", "email", "businessRegistrationCountry", "businessRegistrationStateProvince", - "businessRegistrationId", "businessOperatingName"); + "businessRegistrationId", "businessOperatingName", "language"); assertThat(result.getClientUserId()).isEqualTo(CLIENT_USER_ID); assertThat(result.getBusinessName()).isEqualTo(COMPANY_NAME); assertThat(result.getBusinessOperatingName()).isEqualTo(BUSINESS_NAME); @@ -184,6 +188,7 @@ void convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheProfessionalSeller assertThat(result.getBusinessRegistrationCountry()).isEqualTo(COMPANY_REGISTRATION_COUNTRY); assertThat(result.getBusinessRegistrationStateProvince()).isEqualTo(BUSINESS_REGISTRATION_STATE_PROVINCE); assertThat(result.getBusinessRegistrationId()).isEqualTo(COMPANY_REGISTRATION_NUMBER); + assertThat(result.getLanguage()).isEqualTo(LANGUAGE); } @Test @@ -215,6 +220,7 @@ void convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheIndividualSellerMo assertThat(result.getBusinessType()).isEqualTo(HyperwalletUser.BusinessType.PRIVATE_COMPANY); assertThat(result.getGovernmentIdType()).isEqualTo(HyperwalletUser.GovernmentIdType.NATIONAL_ID_CARD); assertThat(result.getToken()).isEqualTo(USER_TOKEN); + assertThat(result.getLanguage()).isEqualTo(LANGUAGE); } } diff --git a/hmc-sellers/src/test/java/com/paypal/sellers/utils/LanguageConverterTest.java b/hmc-sellers/src/test/java/com/paypal/sellers/utils/LanguageConverterTest.java new file mode 100644 index 00000000..96c5a5f2 --- /dev/null +++ b/hmc-sellers/src/test/java/com/paypal/sellers/utils/LanguageConverterTest.java @@ -0,0 +1,67 @@ +package com.paypal.sellers.utils; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; + +import java.util.List; +import java.util.Locale; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@ExtendWith(MockitoExtension.class) +class LanguageConverterTest { + + private static final String SUPPORTED_LANGUAGES = "supportedLanguages"; + + private static final String DEFAULT_LANGUAGE = "defaultLanguage"; + + @InjectMocks + @Spy + private LanguageConverter testObj; + + @BeforeEach + void setUp() { + final List supportedLanguages = List.of("en", "fr", "es", "de", "it", "nl", "pt"); + ReflectionTestUtils.setField(testObj, DEFAULT_LANGUAGE, "en"); + ReflectionTestUtils.setField(testObj, SUPPORTED_LANGUAGES, supportedLanguages); + } + + @Test + void convert_shouldReturnENLanguageWhenLocaleIsUS() { + + final String result = testObj.convert(Locale.US); + + assertEquals("en", result); + } + + @Test + void convert_shouldReturnFRLanguageWhenLocaleIsFRANCE() { + + final String result = testObj.convert(Locale.FRANCE); + + assertEquals("fr", result); + } + + @Test + void convert_shouldReturnzh_CNLanguageWhenLocaleIsChinaSimplified() { + + final String result = testObj.convert(Locale.CHINA); + + assertEquals("zh_CN", result); + } + + @Test + void convert_shouldReturnENLanguageWhenLocaleIsNotSupported() { + final Locale locale = new Locale("fi", "FI"); + + final String result = testObj.convert(locale); + + assertEquals("en", result); + } + +} \ No newline at end of file diff --git a/hmc-testsupport/src/main/resources/application-test.properties b/hmc-testsupport/src/main/resources/application-test.properties index 7f64c4a1..011ca3fc 100644 --- a/hmc-testsupport/src/main/resources/application-test.properties +++ b/hmc-testsupport/src/main/resources/application-test.properties @@ -103,6 +103,7 @@ hmc.toggle-features.http-capture = ${PAYPAL_HYPERWALLET_HTTP hmc.webhooks.payments.failure-statuses = FAILED,RECALLED,RETURNED,EXPIRED,UNCLAIMED,CANCELLED hmc.webhooks.payments.accepted-statuses = COMPLETED +hmc.webhooks.payments.confirm-linked-manual-documents = true hmc.webhooks.routing-keys.payments = PAYMENTS hmc.webhooks.routing-keys.kyc-users = USERS.UPDATED.VERIFICATION_STATUS hmc.webhooks.routing-keys.kyc-bstk = USERS.BUSINESS_STAKEHOLDERS @@ -115,3 +116,8 @@ hmc.startup-checks.exit-on-fail = false hmc.financial-reports.outputdir = /home/reports/ hmc.financial-reports.header = braintreeCommerceOrderId,miraklOrderId,miraklSellerId,miraklTransactionLineId,miraklTransactionTime,TransactionType,braintreeAmount,miraklDebitAmount,miraklCreditAmount,currencyIsoCode,braintreeTransactionId,braintreeTransactionTime hmc.financial-reports.filename-prefix = financialReport + +hmc.hyperwallet.supported.languages = en,fr,es,de,it,nl,pt +hmc.hyperwallet.default.language = en + +hmc.hyperwallet.countries.not.local.tax = KOR,USA