From 11e319ab1a3bce62812aa9fafc05172b613a121f Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 18 Jun 2024 07:41:25 +0000 Subject: [PATCH 1/2] [PAGOPA-1831] disable cart: managed disabling for cart-type transactions --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- openapi/openapi_ec.json | 2 +- openapi/openapi_helpdesk.json | 2 +- openapi/openapi_io.json | 2 +- openapi/openapi_io_patch.json | 4 ++-- pom.xml | 2 +- .../service/impl/TransactionService.java | 15 +++++++++------ 11 files changed, 21 insertions(+), 18 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index e399004e..c9a649a4 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-biz-events-service description: Microservice for exposing REST APIs about payment receipts. type: application -version: 0.58.0 -appVersion: 0.1.36 +version: 0.59.0 +appVersion: 0.1.37 dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 0c4e93d8..7875992e 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-biz-events-service - tag: "0.1.36" + tag: "0.1.37" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a5c2e3e5..63e949c2 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-biz-events-service - tag: "0.1.36" + tag: "0.1.37" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 4cfe0df2..bb40633f 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-biz-events-service - tag: "0.1.36" + tag: "0.1.37" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index f42d18a3..02ccab48 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_ec.json b/openapi/openapi_ec.json index 3ed027af..74ecd3f1 100644 --- a/openapi/openapi_ec.json +++ b/openapi/openapi_ec.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_helpdesk.json b/openapi/openapi_helpdesk.json index 964e3c59..27aa0809 100644 --- a/openapi/openapi_helpdesk.json +++ b/openapi/openapi_helpdesk.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_io.json b/openapi/openapi_io.json index 721b282f..23b4d239 100644 --- a/openapi/openapi_io.json +++ b/openapi/openapi_io.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_io_patch.json b/openapi/openapi_io_patch.json index ebc1f93b..f7305af8 100644 --- a/openapi/openapi_io_patch.json +++ b/openapi/openapi_io_patch.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { @@ -955,7 +955,7 @@ "type": "http", "scheme": "bearer", "description": "JWT token associated to the user" - } + } } } } diff --git a/pom.xml b/pom.xml index ad1104b9..d2294b91 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ it.gov.pagopa bizeventsservice - 0.1.36 + 0.1.37 Biz-Events Service Microservice for exposing REST APIs about payment receipts. diff --git a/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java b/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java index addc4a03..71741f48 100644 --- a/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java +++ b/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java @@ -161,14 +161,17 @@ public TransactionDetailResponse getTransactionDetails(String taxCode, String ev @Override public void disableTransaction(String fiscalCode, String transactionId) { - List listOfViewUser = this.bizEventsViewUserRepository + + List listOfViewUser = this.bizEventsViewUserRepository .getBizEventsViewUserByTaxCodeAndTransactionId(fiscalCode, transactionId); - if (listOfViewUser.size() != 1) { + + if (CollectionUtils.isEmpty(listOfViewUser)) { throw new AppException(AppError.VIEW_USER_NOT_FOUND_WITH_TRANSACTION_ID, fiscalCode, transactionId); - } - BizEventsViewUser bizEventsViewUser = listOfViewUser.get(0); - bizEventsViewUser.setHidden(true); - bizEventsViewUserRepository.save(bizEventsViewUser); + } + + // PAGOPA-1831: set hidden to true for all transactions with the same transactionId for the given fiscalCode + listOfViewUser.forEach(u -> u.setHidden(true)); + bizEventsViewUserRepository.saveAll(listOfViewUser); } private List> retrievePaginatedList (String taxCode, Integer size) { From be8424a13499309722ce4f2a20a83bbd38b6544f Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 18 Jun 2024 07:41:25 +0000 Subject: [PATCH 2/2] [PAGOPA-1831] disable cart: add junit test --- helm/Chart.yaml | 4 +-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- openapi/openapi_ec.json | 2 +- openapi/openapi_helpdesk.json | 2 +- openapi/openapi_io.json | 2 +- openapi/openapi_io_patch.json | 4 +-- pom.xml | 2 +- .../service/impl/TransactionService.java | 15 +++++---- .../service/TransactionServiceTest.java | 31 +++++++++++++++++-- .../bizeventsservice/util/ViewGenerator.java | 1 + 13 files changed, 51 insertions(+), 20 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index e399004e..c9a649a4 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-biz-events-service description: Microservice for exposing REST APIs about payment receipts. type: application -version: 0.58.0 -appVersion: 0.1.36 +version: 0.59.0 +appVersion: 0.1.37 dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 0c4e93d8..7875992e 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-biz-events-service - tag: "0.1.36" + tag: "0.1.37" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a5c2e3e5..63e949c2 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-biz-events-service - tag: "0.1.36" + tag: "0.1.37" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 4cfe0df2..bb40633f 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-biz-events-service - tag: "0.1.36" + tag: "0.1.37" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index f42d18a3..02ccab48 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_ec.json b/openapi/openapi_ec.json index 3ed027af..74ecd3f1 100644 --- a/openapi/openapi_ec.json +++ b/openapi/openapi_ec.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_helpdesk.json b/openapi/openapi_helpdesk.json index 964e3c59..27aa0809 100644 --- a/openapi/openapi_helpdesk.json +++ b/openapi/openapi_helpdesk.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_io.json b/openapi/openapi_io.json index 721b282f..23b4d239 100644 --- a/openapi/openapi_io.json +++ b/openapi/openapi_io.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { diff --git a/openapi/openapi_io_patch.json b/openapi/openapi_io_patch.json index ebc1f93b..f7305af8 100644 --- a/openapi/openapi_io_patch.json +++ b/openapi/openapi_io_patch.json @@ -4,7 +4,7 @@ "title": "Biz-Events Service", "description": "Microservice for exposing REST APIs about payment receipts.", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.1.36" + "version": "0.1.37" }, "servers": [ { @@ -955,7 +955,7 @@ "type": "http", "scheme": "bearer", "description": "JWT token associated to the user" - } + } } } } diff --git a/pom.xml b/pom.xml index ad1104b9..d2294b91 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ it.gov.pagopa bizeventsservice - 0.1.36 + 0.1.37 Biz-Events Service Microservice for exposing REST APIs about payment receipts. diff --git a/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java b/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java index addc4a03..71741f48 100644 --- a/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java +++ b/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java @@ -161,14 +161,17 @@ public TransactionDetailResponse getTransactionDetails(String taxCode, String ev @Override public void disableTransaction(String fiscalCode, String transactionId) { - List listOfViewUser = this.bizEventsViewUserRepository + + List listOfViewUser = this.bizEventsViewUserRepository .getBizEventsViewUserByTaxCodeAndTransactionId(fiscalCode, transactionId); - if (listOfViewUser.size() != 1) { + + if (CollectionUtils.isEmpty(listOfViewUser)) { throw new AppException(AppError.VIEW_USER_NOT_FOUND_WITH_TRANSACTION_ID, fiscalCode, transactionId); - } - BizEventsViewUser bizEventsViewUser = listOfViewUser.get(0); - bizEventsViewUser.setHidden(true); - bizEventsViewUserRepository.save(bizEventsViewUser); + } + + // PAGOPA-1831: set hidden to true for all transactions with the same transactionId for the given fiscalCode + listOfViewUser.forEach(u -> u.setHidden(true)); + bizEventsViewUserRepository.saveAll(listOfViewUser); } private List> retrievePaginatedList (String taxCode, Integer size) { diff --git a/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java b/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java index 795ce476..47d5e3cd 100644 --- a/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java +++ b/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java @@ -23,6 +23,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.jupiter.api.*; +import org.mockito.ArgumentCaptor; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; @@ -35,9 +36,11 @@ import java.util.*; import static it.gov.pagopa.bizeventsservice.util.ViewGenerator.generateBizEventsViewUser; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; @@ -281,8 +284,32 @@ void transactionViewUserDisabled() { .thenReturn(viewUserList); Assertions.assertDoesNotThrow(() -> transactionService.disableTransaction( ViewGenerator.USER_TAX_CODE_WITH_TX, ViewGenerator.TRANSACTION_ID)); - viewUserList.get(0).setHidden(true); - verify(bizEventsViewUserRepository).save(viewUserList.get(0)); + + ArgumentCaptor> argument = ArgumentCaptor.forClass(List.class); + verify(bizEventsViewUserRepository).saveAll(argument.capture()); + assertEquals(Boolean.TRUE, argument.getValue().get(0).getHidden()); + } + + @Test + void transactionViewUserCartDisabled() { + + List viewUserList = new ArrayList<>(); + + for (int i=0; i<10; i++) { + BizEventsViewUser u = generateBizEventsViewUser(); + u.setId(u.getId()+"_"+i); + viewUserList.add(u); + } + + when(bizEventsViewUserRepository.getBizEventsViewUserByTaxCodeAndTransactionId(anyString(),anyString())) + .thenReturn(viewUserList); + + Assertions.assertDoesNotThrow(() -> transactionService.disableTransaction( + ViewGenerator.USER_TAX_CODE_WITH_TX, ViewGenerator.TRANSACTION_ID)); + + ArgumentCaptor> argument = ArgumentCaptor.forClass(List.class); + verify(bizEventsViewUserRepository).saveAll(argument.capture()); + argument.getValue().forEach(u -> assertEquals(Boolean.TRUE, u.getHidden())); } @Test diff --git a/src/test/java/it/gov/pagopa/bizeventsservice/util/ViewGenerator.java b/src/test/java/it/gov/pagopa/bizeventsservice/util/ViewGenerator.java index 97081365..b87c94d9 100644 --- a/src/test/java/it/gov/pagopa/bizeventsservice/util/ViewGenerator.java +++ b/src/test/java/it/gov/pagopa/bizeventsservice/util/ViewGenerator.java @@ -33,6 +33,7 @@ public class ViewGenerator { public static BizEventsViewUser generateBizEventsViewUser(){ return BizEventsViewUser.builder() + .id(EVENT_ID) .taxCode(USER_TAX_CODE_WITH_TX) .transactionId(TRANSACTION_ID) .transactionDate(TRANSACTION_DATE)