diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImpl.java b/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImpl.java index ce481a0..898bb41 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImpl.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImpl.java @@ -224,7 +224,7 @@ private String getPaymentMethodAccountHolder(BizEvent event) { return null; } - private String getUserFullName(BizEvent event) throws TemplateDataMappingException { + private String getUserFullName(BizEvent event) { if ( event.getTransactionDetails() != null && event.getTransactionDetails().getUser() != null && @@ -238,7 +238,7 @@ private String getUserFullName(BizEvent event) throws TemplateDataMappingExcepti if (event.getPayer() != null && event.getPayer().getFullName() != null) { return event.getPayer().getFullName(); } - throw new TemplateDataMappingException(formatErrorMessage(TemplateDataField.USER_DATA_FULL_NAME, event.getId(), true), ReasonErrorCode.ERROR_TEMPLATE_PDF.getCode()); + return ""; } private String getUserTaxCode(BizEvent event) throws TemplateDataMappingException { diff --git a/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImplTest.java b/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImplTest.java index 15e535e..a9fd2d9 100644 --- a/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/service/impl/BuildTemplateServiceImplTest.java @@ -1875,23 +1875,67 @@ void mapTemplateNoRrnError() { } @Test - void mapTemplateNoUserDataFullNameError() { - List bizEventList = Collections.singletonList(BizEvent.builder() + void mapTemplateUserDataFullNameBlank() { + + List bizEventList = Collections.singletonList(BizEvent.builder() .id(BIZ_EVENT_ID) - .paymentInfo(PaymentInfo.builder() - .IUR(IUR) - .paymentDateTime(DATE_TIME_TIMESTAMP_MILLISECONDS_DST_WINTER) - .amount(AMOUNT_WITHOUT_CENTS) + .idPaymentManager(BIZ_EVENT_ID) + .debtorPosition(DebtorPosition.builder() + .iuv(IUV) + .modelType(MODEL_TYPE_IUV_CODE) + .build()) + .creditor(Creditor.builder() + .companyName(COMPANY_NAME) + .idPA(ID_PA) .build()) .psp(Psp.builder() .idPsp(ID_PSP) .psp(PSP_NAME) .build()) + .debtor(Debtor.builder() + .fullName(DEBTOR_FULL_NAME) + .entityUniqueIdentifierValue(DEBTOR_VALID_CF) + .build()) + // no User Data Full Name in payer and transactionDetails sections + .payer(Payer.builder().entityUniqueIdentifierValue(PAYER_VALID_CF).build()) + .paymentInfo(PaymentInfo.builder() + .paymentDateTime(DATE_TIME_TIMESTAMP_MILLISECONDS_DST_WINTER) + .paymentToken(PAYMENT_TOKEN) + .amount(AMOUNT_WITHOUT_CENTS) + .fee(FEE_WITH_SINGLE_DIGIT_CENTS) + .remittanceInformation(REMITTANCE_INFORMATION) + .IUR(IUR) + .build()) + .transactionDetails(TransactionDetails.builder() + .wallet(WalletItem.builder() + .info(Info.builder().brand(BRAND).holder(HOLDER_FULL_NAME).build()) + .onboardingChannel(PAGO_PA_CHANNEL_IO) + .build()) + .transaction(Transaction.builder() + .idTransaction(ID_TRANSACTION) + .grandTotal(GRAND_TOTAL_LONG) + .amount(AMOUNT_LONG) + .fee(FEE_LONG) + .rrn(RRN) + .numAut(AUTH_CODE) + .creationDate(DATE_TIME_TIMESTAMP_ZONED_DST_SUMMER) + .psp(TransactionPsp.builder() + .businessName(PSP_NAME) + .build()) + .origin(PAGOPA_PA_CHANNEL_ID) + .build()) + .build()) + .eventStatus(BizEventStatusType.DONE) .build()); - TemplateDataMappingException e = assertThrows(TemplateDataMappingException.class, () -> buildTemplateService.buildTemplate(bizEventList, GENERATED_BY_PAYER, Receipt.builder().eventId(BIZ_EVENT_ID).eventData(EventData.builder().amount(FORMATTED_GRAND_TOTAL).build()).build())); + + Receipt receipt = Receipt.builder().eventId(BIZ_EVENT_ID).eventData(EventData.builder().amount(FORMATTED_GRAND_TOTAL).cart(List.of(CartItem.builder().subject(REMITTANCE_INFORMATION).build())).build()).build(); + + AtomicReference atomicReference = new AtomicReference<>(); + assertDoesNotThrow(() -> atomicReference.set(buildTemplateService.buildTemplate(bizEventList, GENERATED_BY_PAYER, receipt))); - assertEquals(ReasonErrorCode.ERROR_TEMPLATE_PDF.getCode(), e.getStatusCode()); - assertEquals(String.format(TemplateDataField.ERROR_MAPPING_MESSAGE, BIZ_EVENT,TemplateDataField.USER_DATA_FULL_NAME, BIZ_EVENT,BIZ_EVENT_ID), e.getMessage()); + ReceiptPDFTemplate receiptPdfTemplate = atomicReference.get(); + + assertEquals("",receiptPdfTemplate.getUser().getData().getFullName()); } @Test