diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/message/IOMessage.java b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/message/IOMessage.java index 722a43c..887d431 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/message/IOMessage.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/message/IOMessage.java @@ -1,12 +1,12 @@ package it.gov.pagopa.receipt.pdf.notifier.entity.message; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; @Getter @Setter @NoArgsConstructor +@AllArgsConstructor +@Builder public class IOMessage { String messageId; diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/ReasonError.java b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/ReasonError.java index a855c13..bba8225 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/ReasonError.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/ReasonError.java @@ -1,14 +1,12 @@ package it.gov.pagopa.receipt.pdf.notifier.entity.receipt; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; @Getter @Setter @NoArgsConstructor @AllArgsConstructor +@Builder public class ReasonError { private int code; private String message; diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/Receipt.java b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/Receipt.java index fcf4db8..4dda6a6 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/Receipt.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/entity/receipt/Receipt.java @@ -20,6 +20,7 @@ public class Receipt { private ReceiptMetadata mdAttachPayer; private int numRetry; private ReasonError reasonErr; + private ReasonError reasonErrPayer; private int notificationNumRetry; private long inserted_at; private long generated_at; diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/ReceiptToIOService.java b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/ReceiptToIOService.java index f9c031a..8ebe44f 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/ReceiptToIOService.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/ReceiptToIOService.java @@ -10,8 +10,25 @@ import java.util.List; public interface ReceiptToIOService { + + /** + * Handles IO user validation and notification + * + * @param fiscalCode User fiscal code + * @param userType Enum User type + * @param receipt the Receipt + * @return the status of the notification {@link UserNotifyStatus} + */ UserNotifyStatus notifyMessage(String fiscalCode, UserType userType, Receipt receipt); + /** + * Verifies if all users have been notified + * + * @param usersToBeVerified Map containing user notification status + * @param messagesNotified List of messages with message id to be saved on CosmosDB + * @param receipt Receipt to update and save on CosmosDB + * @return true if a message has been sent to queue, false otherwise + */ boolean verifyMessagesNotification( EnumMap usersToBeVerified, List messagesNotified, diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImpl.java b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImpl.java index 8781f3a..98d5a34 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImpl.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImpl.java @@ -6,7 +6,6 @@ import it.gov.pagopa.receipt.pdf.notifier.client.NotifierQueueClient; import it.gov.pagopa.receipt.pdf.notifier.client.impl.NotifierQueueClientImpl; import it.gov.pagopa.receipt.pdf.notifier.entity.message.IOMessage; -import it.gov.pagopa.receipt.pdf.notifier.entity.receipt.EventData; import it.gov.pagopa.receipt.pdf.notifier.entity.receipt.IOMessageData; import it.gov.pagopa.receipt.pdf.notifier.entity.receipt.ReasonError; import it.gov.pagopa.receipt.pdf.notifier.entity.receipt.Receipt; @@ -26,7 +25,6 @@ import it.gov.pagopa.receipt.pdf.notifier.service.ReceiptToIOService; import it.gov.pagopa.receipt.pdf.notifier.utils.ObjectMapperUtils; import org.apache.http.HttpStatus; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +33,8 @@ import java.util.EnumMap; import java.util.List; +import static it.gov.pagopa.receipt.pdf.notifier.model.enumeration.UserNotifyStatus.*; + public class ReceiptToIOServiceImpl implements ReceiptToIOService { private final Logger logger = LoggerFactory.getLogger(ReceiptToIOServiceImpl.class); @@ -59,31 +59,31 @@ public ReceiptToIOServiceImpl() { } /** - * Handles IO user validation and notification - * - * @param fiscalCode User fiscal code - * @param userType Enum User type - * @param receipt the Receipt - * @return the status of the notification {@link UserNotifyStatus} + * {@inheritDoc} */ @Override public UserNotifyStatus notifyMessage(String fiscalCode, UserType userType, Receipt receipt) { if (!isToBeNotified(fiscalCode, userType, receipt)) { - return UserNotifyStatus.NOT_TO_BE_NOTIFIED; + return NOT_TO_BE_NOTIFIED; } try { boolean isNotifyAllowed = handleGetProfile(fiscalCode); if (!isNotifyAllowed) { logger.info("User {} has not to be notified", userType); - return UserNotifyStatus.NOT_TO_BE_NOTIFIED; + return NOT_TO_BE_NOTIFIED; } //Send notification to user handleSendNotificationToUser(fiscalCode, userType, receipt); - return UserNotifyStatus.NOTIFIED; + return NOTIFIED; } catch (Exception e) { + if (userType.equals(UserType.DEBTOR)) { + receipt.setReasonErr(buildReasonError(e.getMessage())); + } else { + receipt.setReasonErrPayer(buildReasonError(e.getMessage())); + } logger.error("Error notifying IO user {}", userType, e); - return UserNotifyStatus.NOT_NOTIFIED; + return NOT_NOTIFIED; } } @@ -146,12 +146,7 @@ private void handleSendNotificationToUser(String fiscalCode, UserType userType, } /** - * Verifies if all users have been notified - * - * @param usersToBeVerified Map containing user notification status - * @param messagesNotified List of messages with message id to be saved on CosmosDB - * @param receipt Receipt to update and save on CosmosDB - * @return 1 if a message has been sent to queue + * {@inheritDoc} */ @Override public boolean verifyMessagesNotification( @@ -159,160 +154,56 @@ public boolean verifyMessagesNotification( List messagesNotified, Receipt receipt ) throws JsonProcessingException { - String errorMessage = ""; - EventData eventData = receipt.getEventData(); - String debtorCF = eventData.getDebtorFiscalCode(); - String payerCF = eventData.getPayerFiscalCode(); - UserNotifyStatus debtorNotified = getUserNotifyStatus(debtorCF, usersToBeVerified.get(UserType.DEBTOR)); - UserNotifyStatus payerNotified = getUserNotifyStatus(payerCF, usersToBeVerified.get(UserType.PAYER)); - boolean queueSent = false; - - if (receipt.getIoMessageData() != null) { - IOMessageData messageData = receipt.getIoMessageData(); - - //Verify notification to debtor user - errorMessage = handleMessageMetadata( - messagesNotified, - receipt, - debtorNotified, - messageData, - UserType.DEBTOR, - false); - - //Verify notification to payer user - errorMessage = handleMessageMetadata( - messagesNotified, - receipt, - payerNotified, - messageData, - UserType.PAYER, - errorMessage != null); + UserNotifyStatus debtorNotified = usersToBeVerified.getOrDefault(UserType.DEBTOR, NOT_TO_BE_NOTIFIED); + UserNotifyStatus payerNotified = usersToBeVerified.getOrDefault(UserType.PAYER, NOT_TO_BE_NOTIFIED); + if (debtorNotified.equals(NOTIFIED)) { + IOMessage ioMessage = getIoMessage(receipt, UserType.DEBTOR); + messagesNotified.add(ioMessage); } - - if (debtorNotified.equals(UserNotifyStatus.NOT_NOTIFIED) || payerNotified.equals(UserNotifyStatus.NOT_NOTIFIED)) { - queueSent = handleErrorMessageNotification(receipt, errorMessage); - - } else if (debtorNotified.equals(UserNotifyStatus.NOT_TO_BE_NOTIFIED) && - payerNotified.equals(UserNotifyStatus.NOT_TO_BE_NOTIFIED)) { - receipt.setStatus(ReceiptStatusType.NOT_TO_NOTIFY); - - } else { - receipt.setStatus(ReceiptStatusType.IO_NOTIFIED); - receipt.setNotified_at(System.currentTimeMillis()); + if (payerNotified.equals(NOTIFIED)) { + IOMessage ioMessage = getIoMessage(receipt, UserType.PAYER); + messagesNotified.add(ioMessage); } - return queueSent; - } - /** - * Returns the status of the notification process for the given user - * - * @param fiscalCode User fiscal code - * @param userStatus User status from the previous process - * @return final userStatus - */ - private UserNotifyStatus getUserNotifyStatus(String fiscalCode, UserNotifyStatus userStatus) { - return fiscalCode != null && !fiscalCode.isBlank() && userStatus != null - ? - userStatus : UserNotifyStatus.NOT_TO_BE_NOTIFIED; - } - - /** - * Generates message's CosmosDB entry with message id and event id - * - * @param messagesNotified List of messages to be saved on CosmosDB - * @param receipt Receipt containing event id - * @param userNotified User notification status - * @param messageData Message Data containing message id - * @param userType Enum User Type - * @param previousErrorMessageExist Verify if debtor verification went wrong before the payer's one - * @return error message if needed - */ - private String handleMessageMetadata( - List messagesNotified, - Receipt receipt, - UserNotifyStatus userNotified, - IOMessageData messageData, - UserType userType, - boolean previousErrorMessageExist - ) { - if (userNotified != null && messageData != null) { - if (userNotified.equals(UserNotifyStatus.NOTIFIED)) { - IOMessage ioMessage = new IOMessage(); - if (userType.equals(UserType.DEBTOR)) { - ioMessage.setMessageId(messageData.getIdMessageDebtor()); - } else { - ioMessage.setMessageId(messageData.getIdMessagePayer()); - } - ioMessage.setEventId(receipt.getEventId()); - messagesNotified.add(ioMessage); - - } else if (userNotified.equals(UserNotifyStatus.NOT_NOTIFIED)) { - return generateErrorMessage(userType, previousErrorMessageExist); - } + if (debtorNotified.equals(NOT_NOTIFIED) || payerNotified.equals(NOT_NOTIFIED)) { + return requeueReceiptForRetry(receipt); } - return null; - } - /** - * Return correct error message - * - * @param userType Enum user type - * @param previousErrorMessageExist Boolean that indicates if the previous user also had errors - * @return error message - */ - @NotNull - private String generateErrorMessage(UserType userType, boolean previousErrorMessageExist) { - if (previousErrorMessageExist) { - return "Error notifying both users"; - } - if (userType.equals(UserType.DEBTOR)) { - return "Error notifying debtor user"; + if (debtorNotified.equals(NOT_TO_BE_NOTIFIED) && payerNotified.equals(NOT_TO_BE_NOTIFIED)) { + receipt.setStatus(ReceiptStatusType.NOT_TO_NOTIFY); + return false; } - return "Error notifying payer user"; + + receipt.setStatus(ReceiptStatusType.IO_NOTIFIED); + receipt.setNotified_at(System.currentTimeMillis()); + return false; } - /** - * Handles final receipt update with error status and message - * - * @param receipt Receipt to update - * @param errorMessage Error message to be saved on receipt - * @return 1 if a message has been sent to queue - */ - private boolean handleErrorMessageNotification(Receipt receipt, String errorMessage) throws JsonProcessingException { + private boolean requeueReceiptForRetry(Receipt receipt) throws JsonProcessingException { int numRetry = receipt.getNotificationNumRetry(); - boolean messageQueueSent = false; - - ReasonError reasonError = new ReasonError(); - reasonError.setCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); - reasonError.setMessage(errorMessage); - receipt.setReasonErr(reasonError); - receipt.setNotificationNumRetry(numRetry + 1); - logger.info("Error sending notification: {}", errorMessage); - - if (numRetry < MAX_NUMBER_RETRY) { - receipt.setStatus(ReceiptStatusType.IO_ERROR_TO_NOTIFY); - String receiptString = ObjectMapperUtils.writeValueAsString(receipt); - Response response; - try { - response = this.notifierQueueClient.sendMessageToQueue(Base64.getMimeEncoder().encodeToString(receiptString.getBytes())); - if (response.getStatusCode() == com.microsoft.azure.functions.HttpStatus.CREATED.value()) { - messageQueueSent = true; - } - } catch (Exception e) { - logger.error("Error in sending message to queue for receipt with event id: {}. Receipt updated with status UNABLE_TO_SEND", receipt.getEventId(), e); - } - } else { + if (numRetry >= MAX_NUMBER_RETRY) { logger.error("Maximum number of retries for event with event id: {}. Receipt updated with status UNABLE_TO_SEND", receipt.getEventId()); + receipt.setStatus(ReceiptStatusType.UNABLE_TO_SEND); + return false; } - if (!messageQueueSent) { + String receiptString = ObjectMapperUtils.writeValueAsString(receipt); + try { + Response response = this.notifierQueueClient.sendMessageToQueue(Base64.getMimeEncoder().encodeToString(receiptString.getBytes())); + if (response.getStatusCode() == com.microsoft.azure.functions.HttpStatus.CREATED.value()) { + receipt.setStatus(ReceiptStatusType.IO_ERROR_TO_NOTIFY); + return true; + } + receipt.setStatus(ReceiptStatusType.UNABLE_TO_SEND); + return false; + } catch (Exception e) { + logger.error("Error in sending message to queue for receipt with event id: {}. Receipt updated with status UNABLE_TO_SEND", receipt.getEventId(), e); receipt.setStatus(ReceiptStatusType.UNABLE_TO_SEND); + return false; } - - return messageQueueSent; } private boolean isToBeNotified(String fiscalCode, UserType userType, Receipt receipt) { @@ -327,4 +218,20 @@ private boolean verifyMessageIdIsNotPresent(UserType userType, Receipt receipt) || (userType.equals(UserType.PAYER) && receipt.getIoMessageData().getIdMessagePayer() == null); } + + private IOMessage getIoMessage(Receipt receipt, UserType userType) { + IOMessageData ioMessageData = receipt.getIoMessageData(); + String messageId = userType.equals(UserType.DEBTOR) ? ioMessageData.getIdMessageDebtor() : ioMessageData.getIdMessagePayer(); + return IOMessage.builder() + .messageId(messageId) + .eventId(receipt.getEventId()) + .build(); + } + + private ReasonError buildReasonError(String errorMessage) { + return ReasonError.builder() + .code(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .message(errorMessage) + .build(); + } } diff --git a/src/test/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImplTest.java b/src/test/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImplTest.java index 2558975..eee954a 100644 --- a/src/test/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/receipt/pdf/notifier/service/impl/ReceiptToIOServiceImplTest.java @@ -82,8 +82,10 @@ void notifyDebtorWithSuccess() { assertNotNull(receipt.getIoMessageData()); assertNotNull(receipt.getIoMessageData().getIdMessageDebtor()); assertEquals(VALID_DEBTOR_MESSAGE_ID, receipt.getIoMessageData().getIdMessageDebtor()); - + assertNull(receipt.getReasonErr()); + assertNull(receipt.getReasonErrPayer()); } + @Test @SneakyThrows void notifyPayerWithSuccess() { @@ -103,6 +105,8 @@ void notifyPayerWithSuccess() { assertNotNull(receipt.getIoMessageData()); assertNotNull(receipt.getIoMessageData().getIdMessagePayer()); assertEquals(VALID_PAYER_MESSAGE_ID, receipt.getIoMessageData().getIdMessagePayer()); + assertNull(receipt.getReasonErr()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -125,7 +129,8 @@ void notifyDebtorWithSuccessWithMessageData() { assertNotNull(receipt.getIoMessageData()); assertNotNull(receipt.getIoMessageData().getIdMessageDebtor()); assertEquals(VALID_DEBTOR_MESSAGE_ID, receipt.getIoMessageData().getIdMessageDebtor()); - + assertNull(receipt.getReasonErr()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -148,7 +153,8 @@ void notifyPayerWithSuccessWithMessageData() { assertNotNull(receipt.getIoMessageData()); assertNotNull(receipt.getIoMessageData().getIdMessagePayer()); assertEquals(VALID_PAYER_MESSAGE_ID, receipt.getIoMessageData().getIdMessagePayer()); - + assertNull(receipt.getReasonErr()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -161,10 +167,12 @@ void notifyFailNotToBeNotifiedFilterBlock() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_TO_BE_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNull(receipt.getReasonErr()); + assertNull(receipt.getReasonErrPayer()); } @Test - void notifyFailNotNotifiedGetProfileResponseNull() { + void notifyFailDebtorNotNotifiedGetProfileResponseNull() { Receipt receipt = new Receipt(); receipt.setEventId(EVENT_ID); @@ -173,6 +181,26 @@ void notifyFailNotNotifiedGetProfileResponseNull() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNotNull(receipt.getReasonErr()); + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); + assertNotNull(receipt.getReasonErr().getMessage()); + assertNull(receipt.getReasonErrPayer()); + } + + @Test + void notifyFailPayerNotNotifiedGetProfileResponseNull() { + Receipt receipt = new Receipt(); + receipt.setEventId(EVENT_ID); + + UserNotifyStatus userNotifyStatus = sut.notifyMessage(VALID_PAYER_CF, UserType.PAYER, receipt); + + assertNotNull(userNotifyStatus); + assertEquals(UserNotifyStatus.NOT_NOTIFIED, userNotifyStatus); + assertNull(receipt.getIoMessageData()); + assertNull(receipt.getReasonErr()); + assertNotNull(receipt.getReasonErrPayer()); + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErrPayer().getCode()); + assertNotNull(receipt.getReasonErrPayer().getMessage()); } @Test @@ -189,6 +217,10 @@ void notifyFailNotNotifiedGetProfileResponseStatusNotOK() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNotNull(receipt.getReasonErr()); + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); + assertNotNull(receipt.getReasonErr().getMessage()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -205,6 +237,8 @@ void notifyFailNotToBeNotifiedGetProfileResponseNotAllowed() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_TO_BE_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNull(receipt.getReasonErr()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -213,7 +247,8 @@ void notifyFailNotNotifiedBuildMessageException() { ApiResponse getProfileResponse = mockGetProfileResponse(HttpStatus.SC_OK, true); doReturn(getProfileResponse).when(ioClientMock).getProfileByPOSTWithHttpInfo(any()); - doThrow(MissingFieldsForNotificationException.class).when(ioMessageServiceMock).buildNewMessage(anyString(), any(), any()); + String errorMessage = "error message"; + doThrow(new MissingFieldsForNotificationException(errorMessage)).when(ioMessageServiceMock).buildNewMessage(anyString(), any(), any()); Receipt receipt = new Receipt(); receipt.setEventId(EVENT_ID); @@ -223,6 +258,10 @@ void notifyFailNotNotifiedBuildMessageException() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNotNull(receipt.getReasonErr()); + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); + assertEquals(errorMessage, receipt.getReasonErr().getMessage()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -241,6 +280,10 @@ void notifyFailNotNotifiedNotifyReturnException() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNotNull(receipt.getReasonErr()); + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); + assertNotNull(receipt.getReasonErr().getMessage()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -259,6 +302,10 @@ void notifyFailNotNotifiedNotifyResponseNull() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNotNull(receipt.getReasonErr()); + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); + assertNotNull(receipt.getReasonErr().getMessage()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -278,6 +325,10 @@ void notifyFailNotNotifiedNotifyResponseStatusNotCreated() { assertNotNull(userNotifyStatus); assertEquals(UserNotifyStatus.NOT_NOTIFIED, userNotifyStatus); assertNull(receipt.getIoMessageData()); + assertNotNull(receipt.getReasonErr()); + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); + assertNotNull(receipt.getReasonErr().getMessage()); + assertNull(receipt.getReasonErrPayer()); } @Test @@ -352,9 +403,6 @@ void verifyFailDebtorNotNotifiedWithMessageDataNull() { assertTrue(result); assertEquals(ReceiptStatusType.IO_ERROR_TO_NOTIFY, receipt.getStatus()); assertTrue(messagesNotified.isEmpty()); - assertNotNull(receipt.getReasonErr()); - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); - assertEquals("", receipt.getReasonErr().getMessage()); assertEquals(1, receipt.getNotificationNumRetry()); } @@ -380,9 +428,6 @@ void verifyFailDebtorNotNotified() { assertTrue(result); assertEquals(ReceiptStatusType.IO_ERROR_TO_NOTIFY, receipt.getStatus()); assertTrue(messagesNotified.isEmpty()); - assertNotNull(receipt.getReasonErr()); - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); - assertEquals("", receipt.getReasonErr().getMessage()); assertEquals(1, receipt.getNotificationNumRetry()); } @@ -415,9 +460,6 @@ void verifyFailDebtorNotNotifiedPayerNotified() { assertEquals(1, messagesNotified.size()); assertEquals(receipt.getEventId(), messagesNotified.get(0).getEventId()); assertEquals(VALID_PAYER_MESSAGE_ID, messagesNotified.get(0).getMessageId()); - assertNotNull(receipt.getReasonErr()); - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); - //assertEquals("Error notifying debtor user", receipt.getReasonErr().getMessage()); TODO se debtor fallisce ma payer va in success il payer sovrascrive il messaggio di erore del debtor con NULL assertEquals(1, receipt.getNotificationNumRetry()); } @@ -450,9 +492,6 @@ void verifyFailPayerNotNotifiedDebtorNotified() { assertEquals(1, messagesNotified.size()); assertEquals(receipt.getEventId(), messagesNotified.get(0).getEventId()); assertEquals(VALID_DEBTOR_MESSAGE_ID, messagesNotified.get(0).getMessageId()); - assertNotNull(receipt.getReasonErr()); - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); - assertEquals("Error notifying payer user", receipt.getReasonErr().getMessage()); assertEquals(1, receipt.getNotificationNumRetry()); } @@ -479,9 +518,6 @@ void verifyFailDebtorNotNotifiedMaxRetryReached() { assertFalse(result); assertEquals(ReceiptStatusType.UNABLE_TO_SEND, receipt.getStatus()); assertTrue(messagesNotified.isEmpty()); - assertNotNull(receipt.getReasonErr()); - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); - assertEquals("", receipt.getReasonErr().getMessage()); } @Test @@ -506,9 +542,6 @@ void verifyFailDebtorNotNotifiedRequeueRespond500() { assertFalse(result); assertEquals(ReceiptStatusType.UNABLE_TO_SEND, receipt.getStatus()); assertTrue(messagesNotified.isEmpty()); - assertNotNull(receipt.getReasonErr()); - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); - assertEquals("", receipt.getReasonErr().getMessage()); } @Test @@ -532,9 +565,6 @@ void verifyFailDebtorNotNotifiedRequeueThrowException() { assertFalse(result); assertEquals(ReceiptStatusType.UNABLE_TO_SEND, receipt.getStatus()); assertTrue(messagesNotified.isEmpty()); - assertNotNull(receipt.getReasonErr()); - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, receipt.getReasonErr().getCode()); - assertEquals("", receipt.getReasonErr().getMessage()); } @NotNull