From 03e20fb50b966559167b9952722f7193a3265a3c Mon Sep 17 00:00:00 2001 From: "pierpaolo.didato@emeal.nttdata.com" Date: Wed, 7 Feb 2024 18:25:51 +0100 Subject: [PATCH] Fix OnboardingMapper with upperCase on recipientCode --- .../selfcare/onboarding/mapper/OnboardingMapper.java | 9 +++++---- .../onboarding/controller/OnboardingControllerTest.java | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/mapper/OnboardingMapper.java b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/mapper/OnboardingMapper.java index f01d41b67..ce81069da 100644 --- a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/mapper/OnboardingMapper.java +++ b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/mapper/OnboardingMapper.java @@ -14,13 +14,13 @@ @Mapper(componentModel = "cdi") public interface OnboardingMapper { - @Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))") + @Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase") Onboarding toEntity(OnboardingPaRequest request); - @Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))") + @Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase") Onboarding toEntity(OnboardingPspRequest request); - @Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))") + @Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase") Onboarding toEntity(OnboardingDefaultRequest request); - @Mapping(target = "billing.recipientCode", expression = "java(toUpperCase(billing.getRecipientCode()))") + @Mapping(target = "billing.recipientCode", source = "billing.recipientCode", qualifiedByName = "toUpperCase") Onboarding toEntity(OnboardingSaRequest request); @Mapping(source = "taxCode", target = "institution.taxCode") @@ -40,6 +40,7 @@ public interface OnboardingMapper { default String objectIdToString(ObjectId objectId) { return objectId.toHexString(); } + @Named("toUpperCase") default String toUpperCase(String recipientCode) { return Objects.nonNull(recipientCode) ? recipientCode.toUpperCase() : null; diff --git a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/controller/OnboardingControllerTest.java b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/controller/OnboardingControllerTest.java index 9b11fbdcf..ef75b6491 100644 --- a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/controller/OnboardingControllerTest.java +++ b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/controller/OnboardingControllerTest.java @@ -150,6 +150,12 @@ void onboardingPa() { .post("/pa") .then() .statusCode(200); + + ArgumentCaptor captor = ArgumentCaptor.forClass(Onboarding.class); + Mockito.verify(onboardingService, times(1)) + .onboarding(captor.capture(), any()); + assertEquals(captor.getValue().getBilling().getRecipientCode(), onboardingPaValid.getBilling().getRecipientCode().toUpperCase()); + } private OnboardingPaRequest dummyOnboardingPa() {