From 0814065b3e26026e28cb6e62fab6a2f1ee951d69 Mon Sep 17 00:00:00 2001 From: Eugene Grybinnyk Date: Mon, 22 Apr 2024 18:34:22 +0200 Subject: [PATCH] PAYM-5230: Use payments v3 spec --- pom.xml | 27 ++++ .../PaymentOrderPresentationRestClient.java | 6 +- .../configurator/PaymentsConfigurator.java | 6 +- .../ct/bbfuel/data/PaymentsDataGenerator.java | 152 +++++++++--------- src/main/resources/data.properties | 2 +- .../us-productized-data.properties | 2 +- 6 files changed, 111 insertions(+), 84 deletions(-) diff --git a/pom.xml b/pom.xml index acc74a21..17150249 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,7 @@ 2.7.2 2.6.0 2.9.5 + 3.9.0 @@ -472,6 +473,18 @@ contact-manager-integration-inbound-api-v${contact-manager-integration-inbound-api.version}.yaml + + + download-payment-order-client-api-spec + + download-single + + generate-sources + + https://repo.backbase.com/specs/payment + payment-order-client-api-v${payment-order-client-api.version}.yaml + + @@ -642,6 +655,20 @@ + + + generate-payment-order-client-api-client-code + + generate + + + ${api.target}/payment-order-client-api-v${payment-order-client-api.version}.yaml + + com.backbase.dbs.paymentorder.client.api.v3 + com.backbase.dbs.paymentorder.client.api.v3.model + + + diff --git a/src/main/java/com/backbase/ct/bbfuel/client/payment/PaymentOrderPresentationRestClient.java b/src/main/java/com/backbase/ct/bbfuel/client/payment/PaymentOrderPresentationRestClient.java index c8b38c9e..44de3ea4 100644 --- a/src/main/java/com/backbase/ct/bbfuel/client/payment/PaymentOrderPresentationRestClient.java +++ b/src/main/java/com/backbase/ct/bbfuel/client/payment/PaymentOrderPresentationRestClient.java @@ -2,7 +2,7 @@ import com.backbase.ct.bbfuel.client.common.RestClient; import com.backbase.ct.bbfuel.config.BbFuelConfiguration; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder; +import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId; import io.restassured.http.ContentType; import io.restassured.response.Response; import javax.annotation.PostConstruct; @@ -15,7 +15,7 @@ public class PaymentOrderPresentationRestClient extends RestClient { private final BbFuelConfiguration config; - private static final String SERVICE_VERSION = "v2"; + private static final String SERVICE_VERSION = "v3"; private static final String ENDPOINT_PAYMENT_ORDERS = "/payment-orders"; @PostConstruct @@ -25,7 +25,7 @@ public void init() { setInitialPath(config.getDbsServiceNames().getPayments() + "/" + CLIENT_API); } - public Response initiatePaymentOrder(InitiatePaymentOrder body) { + public Response initiatePaymentOrder(InitiatePaymentOrderWithId body) { return requestSpec() .contentType(ContentType.JSON) .body(body) diff --git a/src/main/java/com/backbase/ct/bbfuel/configurator/PaymentsConfigurator.java b/src/main/java/com/backbase/ct/bbfuel/configurator/PaymentsConfigurator.java index ee28c45e..64fa4b91 100644 --- a/src/main/java/com/backbase/ct/bbfuel/configurator/PaymentsConfigurator.java +++ b/src/main/java/com/backbase/ct/bbfuel/configurator/PaymentsConfigurator.java @@ -8,7 +8,7 @@ import com.backbase.ct.bbfuel.data.PaymentsDataGenerator; import com.backbase.ct.bbfuel.util.CommonHelpers; import com.backbase.ct.bbfuel.util.GlobalProperties; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder; +import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId; import com.backbase.dbs.productsummary.presentation.rest.spec.v2.productsummary.ArrangementsByBusinessFunctionGetResponseBody; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -41,6 +41,8 @@ public void ingestPaymentOrders(String externalUserId) { List ootbPaymentTypes = globalProperties.getList(PROPERTY_PAYMENTS_OOTB_TYPES); + log.info("ootbPaymentTypes is {}", String.join(",", ootbPaymentTypes)); + loginRestClient.login(externalUserId, externalUserId); userContextPresentationRestClient.selectContextBasedOnMasterServiceAgreement(); List sepaCtArrangements = productSummaryPresentationRestClient @@ -75,7 +77,7 @@ public void ingestPaymentOrders(String externalUserId) { throw new IllegalArgumentException("Unknown payment type " + paymentType); } - InitiatePaymentOrder initiatePaymentOrder = PaymentsDataGenerator + InitiatePaymentOrderWithId initiatePaymentOrder = PaymentsDataGenerator .generateInitiatePaymentOrder(randomArrangement.getId(), randomArrangement.getCurrency(), paymentType); paymentOrderPresentationRestClient.initiatePaymentOrder(initiatePaymentOrder) .then() diff --git a/src/main/java/com/backbase/ct/bbfuel/data/PaymentsDataGenerator.java b/src/main/java/com/backbase/ct/bbfuel/data/PaymentsDataGenerator.java index b6ff7d1b..d19587ce 100644 --- a/src/main/java/com/backbase/ct/bbfuel/data/PaymentsDataGenerator.java +++ b/src/main/java/com/backbase/ct/bbfuel/data/PaymentsDataGenerator.java @@ -6,29 +6,31 @@ import static com.backbase.ct.bbfuel.util.CommonHelpers.getRandomFromList; import com.backbase.ct.bbfuel.util.CommonHelpers; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.AccountIdentification; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.Bank; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.Identification; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.IdentifiedPaymentOrder; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiateCounterpartyAccount; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiateTransaction; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InvolvedParty; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.PostalAddress; -import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.Schedule; -import com.backbase.rest.spec.common.types.Currency; +import com.backbase.dbs.paymentorder.client.api.v3.model.AccountIdentification; +import com.backbase.dbs.paymentorder.client.api.v3.model.Bank; +import com.backbase.dbs.paymentorder.client.api.v3.model.CurrencyTyped; +import com.backbase.dbs.paymentorder.client.api.v3.model.Identification; +import com.backbase.dbs.paymentorder.client.api.v3.model.InitiateCounterpartyAccount; +import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId; +import com.backbase.dbs.paymentorder.client.api.v3.model.InitiateTransaction; +import com.backbase.dbs.paymentorder.client.api.v3.model.InstructionPriority; +import com.backbase.dbs.paymentorder.client.api.v3.model.InvolvedParty; +import com.backbase.dbs.paymentorder.client.api.v3.model.PaymentMode; +import com.backbase.dbs.paymentorder.client.api.v3.model.PostalAddress; +import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule; +import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule.EveryEnum; +import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule.NonWorkingDayExecutionStrategyEnum; +import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule.TransferFrequencyEnum; +import com.backbase.dbs.paymentorder.client.api.v3.model.SchemeNames; import com.github.javafaker.Faker; -import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.Arrays; -import java.util.Date; import java.util.List; -import java.util.Random; -import org.apache.commons.lang.time.DateUtils; +import java.util.UUID; public class PaymentsDataGenerator { private static Faker faker = new Faker(); - private static Random random = new Random(); private static List branchCodes = Arrays .asList("114923756", "114910222", "124000054", "113011258", "113110586", "121002042", "122003396", "122232109", "122237625", "122237997", "122238572", "122105045", "122105171", "122105320", "122400779", "123006965", @@ -42,26 +44,23 @@ public class PaymentsDataGenerator { "NWBKGB2LXXX", "COBADEFFXXX", "BNPAFRPPXXX", "POALILITXXX", "LOYDGB2LXXX", "NTSBDEB1XXX", "DEUTDEDBPAL", "AXISINBB002"); - public static InitiatePaymentOrder generateInitiatePaymentOrder(String originatorArrangementId, + public static InitiatePaymentOrderWithId generateInitiatePaymentOrder(String originatorArrangementId, String originatorArrangementCurrency, String paymentType) { - IdentifiedPaymentOrder.PaymentMode paymentMode = IdentifiedPaymentOrder.PaymentMode.values()[random - .nextInt(IdentifiedPaymentOrder.PaymentMode.values().length)]; + PaymentMode paymentMode = getRandomFromEnumValues(PaymentMode.values()); Schedule schedule = null; Bank counterpartyBank = null; Bank correspondentBank = null; - Currency currency = new Currency().withAmount(CommonHelpers.generateRandomAmountInRange(1000L, 99999L)); + CurrencyTyped currency = new CurrencyTyped().amount(CommonHelpers.generateRandomAmountInRange(1000L, 99999L)); Identification identification; - if (paymentMode.equals(IdentifiedPaymentOrder.PaymentMode.RECURRING)) { + if (paymentMode == PaymentMode.RECURRING) { schedule = new Schedule() - .withStartDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) - .withEvery(getRandomFromEnumValues(Schedule.Every.values())) - .withNonWorkingDayExecutionStrategy( - getRandomFromEnumValues(Schedule.NonWorkingDayExecutionStrategy.values())) - .withTransferFrequency( - getRandomFromEnumValues(Schedule.TransferFrequency.values())) - .withOn(CommonHelpers.generateRandomNumberInRange(1, 7)) - .withEndDate(new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.addYears(new Date(), 1))); + .startDate(LocalDate.now()) + .every(getRandomFromEnumValues(EveryEnum.values())) + .nonWorkingDayExecutionStrategy(getRandomFromEnumValues(NonWorkingDayExecutionStrategyEnum.values())) + .transferFrequency(getRandomFromEnumValues(TransferFrequencyEnum.values())) + .on(CommonHelpers.generateRandomNumberInRange(1, 7)) + .endDate(LocalDate.now().plusYears(1L)); } if (PAYMENT_TYPE_SEPA_CREDIT_TRANSFER.equals(paymentType)) { @@ -78,69 +77,68 @@ public static InitiatePaymentOrder generateInitiatePaymentOrder(String originato identification = generateBbanIdentification(); } - return new InitiatePaymentOrder() - .withOriginatorAccount(new AccountIdentification() - .withName(faker.lorem().sentence(3, 0).replace(".", "")) - .withIdentification(new Identification().withSchemeName(Identification.SchemeName.ID) - .withIdentification(originatorArrangementId))) - .withBatchBooking(false) - .withInstructionPriority(IdentifiedPaymentOrder.InstructionPriority.values()[random - .nextInt(IdentifiedPaymentOrder.InstructionPriority.values().length)]) - .withPaymentMode(paymentMode) - .withPaymentType(paymentType) - .withRequestedExecutionDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) - .withSchedule(schedule) - .withTransferTransactionInformation(new InitiateTransaction() - .withEndToEndIdentification(faker.lorem().characters(10)) - .withCounterpartyAccount(new InitiateCounterpartyAccount() - .withName(faker.lorem().sentence(3, 0).replace(".", "")) - .withIdentification(identification)) - .withInstructedAmount(currency) - .withRemittanceInformation(faker.lorem().sentence(3, 0).replace(".", "")) - .withCounterparty(new InvolvedParty() - .withName(faker.name().fullName()) - .withPostalAddress(new PostalAddress() - .withAddressLine1(faker.address().streetAddress()) - .withAddressLine2(faker.address().secondaryAddress()) - .withStreetName(faker.address().streetAddress()) - .withPostCode(faker.address().zipCode()) - .withTown(faker.address().city()) - .withCountry(faker.address().countryCode()) - .withCountrySubDivision(faker.address().state()))) - .withCounterpartyBank(counterpartyBank) - .withCorrespondentBank(correspondentBank)); + return new InitiatePaymentOrderWithId() + .id(UUID.randomUUID().toString()) + .originatorAccount(new AccountIdentification() + .name(faker.lorem().sentence(3, 0).replace(".", "")) + .identification( + new Identification().schemeName(SchemeNames.ID).identification(originatorArrangementId))) + .instructionPriority(getRandomFromEnumValues(InstructionPriority.values())) + .paymentMode(paymentMode) + .paymentType(paymentType) + .requestedExecutionDate(LocalDate.now()) + .schedule(schedule) + .transferTransactionInformation(new InitiateTransaction() + .endToEndIdentification(faker.lorem().characters(10)) + .counterpartyAccount(new InitiateCounterpartyAccount() + .name(faker.lorem().sentence(3, 0).replace(".", "")) + .identification(identification)) + .instructedAmount(currency) + .remittanceInformation(faker.lorem().sentence(3, 0).replace(".", "")) + .counterparty(new InvolvedParty() + .name(faker.name().fullName()) + .postalAddress(new PostalAddress() + .addressLine1(faker.address().streetAddress()) + .addressLine2(faker.address().secondaryAddress()) + .streetName(faker.address().streetAddress()) + .postCode(faker.address().zipCode()) + .town(faker.address().city()) + .country(faker.address().countryCode()) + .countrySubDivision(faker.address().state()))) + .counterpartyBank(counterpartyBank) + .correspondentBank(correspondentBank)); } private static Identification generateIbanIdentification() { return new Identification() - .withSchemeName(Identification.SchemeName.IBAN) - .withIdentification(ProductSummaryDataGenerator.generateRandomIban()); + .schemeName(SchemeNames.IBAN) + .identification(ProductSummaryDataGenerator.generateRandomIban()); } private static Identification generateBbanIdentification() { return new Identification() - .withSchemeName(Identification.SchemeName.BBAN) - .withIdentification(String.valueOf(CommonHelpers.generateRandomNumberInRange(0, 999999999))); + .schemeName(SchemeNames.BBAN) + .identification(String.valueOf(CommonHelpers.generateRandomNumberInRange(0, 999999999))); } private static Bank generateCorrespondentBank() { return new Bank() - .withBankBranchCode(getRandomFromList(branchCodes)) - .withName(faker.name().fullName()); + .bankBranchCode(getRandomFromList(branchCodes)) + .name(faker.name().fullName()); } private static Bank generateCounterpartyBank() { return new Bank() - .withBankBranchCode(getRandomFromList(branchCodes)) - .withName(faker.name().fullName()) - .withBic(getRandomFromList(bicCodes)) - .withPostalAddress(new PostalAddress() - .withAddressLine1(faker.address().streetAddress()) - .withAddressLine2(faker.address().secondaryAddress()) - .withStreetName(faker.address().streetAddress()) - .withPostCode(faker.address().zipCode()) - .withTown(faker.address().city()) - .withCountry(faker.address().countryCode()) - .withCountrySubDivision(faker.address().state())); + .bankBranchCode(getRandomFromList(branchCodes)) + .name(faker.name().fullName()) + .bic(getRandomFromList(bicCodes)) + .postalAddress(new PostalAddress() + .addressLine1(faker.address().streetAddress()) + .addressLine2(faker.address().secondaryAddress()) + .streetName(faker.address().streetAddress()) + .postCode(faker.address().zipCode()) + .town(faker.address().city()) + .country(faker.address().countryCode()) + .countrySubDivision(faker.address().state())); } } diff --git a/src/main/resources/data.properties b/src/main/resources/data.properties index f8fb7e6c..3aefe1a2 100644 --- a/src/main/resources/data.properties +++ b/src/main/resources/data.properties @@ -62,7 +62,7 @@ payments.min=10 payments.max=30 # Available OOTB payment types: SEPA_CREDIT_TRANSFER/US_DOMESTIC_WIRE/ACH_DEBIT/US_FOREIGN_WIRE # This is a comma (,) separated value -payments.ootb.types=SEPA_CREDIT_TRANSFER,US_DOMESTIC_WIRE,ACH_DEBIT,US_FOREIGN_WIRE +payments.ootb.types=SEPA_CREDIT_TRANSFER,US_FOREIGN_WIRE # Number of messages ingest.messages=false diff --git a/src/main/resources/data/us-productized-dataset/us-productized-data.properties b/src/main/resources/data/us-productized-dataset/us-productized-data.properties index 85b771bd..a82f079e 100644 --- a/src/main/resources/data/us-productized-dataset/us-productized-data.properties +++ b/src/main/resources/data/us-productized-dataset/us-productized-data.properties @@ -72,7 +72,7 @@ payments.min=10 payments.max=30 # Available OOTB payment types: SEPA_CREDIT_TRANSFER/US_DOMESTIC_WIRE/ACH_DEBIT/US_FOREIGN_WIRE # This is a comma (,) separated value -payments.ootb.types=US_DOMESTIC_WIRE,ACH_DEBIT +payments.ootb.types=US_DOMESTIC_WIRE,US_FOREIGN_WIRE # Number of messages ingest.messages=false