From a01dc1cdc24454a45a142dcf8d27910484e6bf87 Mon Sep 17 00:00:00 2001 From: giomella Date: Mon, 18 Dec 2023 18:25:36 +0100 Subject: [PATCH] added env to customize limit on io error to notify massive recover --- helm/values-dev.yaml | 1 + helm/values-prod.yaml | 1 + helm/values-uat.yaml | 1 + .../utils/RecoverNotNotifiedReceiptUtils.java | 4 +++- .../RecoverNotNotifiedReceiptMassiveTest.java | 14 ++------------ 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index d15de77..3ba2023 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -116,6 +116,7 @@ microservice-chart: NOT_NOTIFIED_AUTORECOVER_ENABLED: "true" RECOVER_FAILED_MASSIVE_MAX_DAYS: "0" RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0" + IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES: "2" envConfigMapExternals: template-maps: BRAND_LOGO_MAP: brand-logo-map diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 0ad8e5c..99e1591 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -116,6 +116,7 @@ microservice-chart: NOT_NOTIFIED_AUTORECOVER_ENABLED: "true" RECOVER_FAILED_MASSIVE_MAX_DAYS: "0" RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0" + IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES: "2" envConfigMapExternals: template-maps: BRAND_LOGO_MAP: brand-logo-map diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index c917c99..1fae68e 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -116,6 +116,7 @@ microservice-chart: NOT_NOTIFIED_AUTORECOVER_ENABLED: "true" RECOVER_FAILED_MASSIVE_MAX_DAYS: "0" RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0" + IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES: "2" envConfigMapExternals: template-maps: BRAND_LOGO_MAP: brand-logo-map diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/RecoverNotNotifiedReceiptUtils.java b/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/RecoverNotNotifiedReceiptUtils.java index 2604f44..e56dd7f 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/RecoverNotNotifiedReceiptUtils.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/RecoverNotNotifiedReceiptUtils.java @@ -10,6 +10,8 @@ public class RecoverNotNotifiedReceiptUtils { + private static final int IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES = Integer.parseInt(System.getenv().getOrDefault("IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES", "2")); + public static Receipt restoreReceipt(Receipt receipt) { receipt.setStatus(ReceiptStatusType.GENERATED); receipt.setNotificationNumRetry(0); @@ -40,7 +42,7 @@ public static List receiptMassiveRestore(ReceiptStatusType statusType, continuationToken = page.getContinuationToken(); } totalPages++; - } while (continuationToken != null && totalPages < 10); + } while (continuationToken != null && totalPages < IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES); return receiptList; } diff --git a/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverNotNotifiedReceiptMassiveTest.java b/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverNotNotifiedReceiptMassiveTest.java index c5f0bec..3d8d899 100644 --- a/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverNotNotifiedReceiptMassiveTest.java +++ b/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverNotNotifiedReceiptMassiveTest.java @@ -33,7 +33,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -124,18 +123,9 @@ void recoverNotNotifiedReceiptMassiveForIOErrorToNotifySuccessWithMoreThan10Page FeedResponse feedResponseMock = mock(FeedResponse.class); when(feedResponseMock.getResults()) .thenReturn(Collections.singletonList(buildReceipt(ReceiptStatusType.IO_ERROR_TO_NOTIFY))); - when(feedResponseMock.getContinuationToken()) - .thenReturn("token", "token", "token", "token", "token", "token", "token", "token", "token", "token"); + when(feedResponseMock.getContinuationToken()).thenReturn("token", "token"); when(receiptCosmosServiceMock.getNotNotifiedReceiptByStatus(any(), any(), any())) .thenReturn(Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), - Collections.singletonList(feedResponseMock), Collections.singletonList(feedResponseMock), Collections.singletonList(feedResponseMock), Collections.singletonList(feedResponseMock)); @@ -155,7 +145,7 @@ void recoverNotNotifiedReceiptMassiveForIOErrorToNotifySuccessWithMoreThan10Page verify(documentReceipts).setValue(receiptCaptor.capture()); - assertEquals(10, receiptCaptor.getValue().size()); + assertEquals(2, receiptCaptor.getValue().size()); } @Test