Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [PagoPa-1831] disable cart transactions #73

Merged
merged 5 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_ec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_helpdesk.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_io.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
4 changes: 2 additions & 2 deletions openapi/openapi_io_patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -955,7 +955,7 @@
"type": "http",
"scheme": "bearer",
"description": "JWT token associated to the user"
}
}
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>bizeventsservice</artifactId>
<version>0.1.36</version>
<version>0.1.37</version>
<name>Biz-Events Service</name>
<description>Microservice for exposing REST APIs about payment receipts.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,17 @@ public TransactionDetailResponse getTransactionDetails(String taxCode, String ev

@Override
public void disableTransaction(String fiscalCode, String transactionId) {
List<BizEventsViewUser> listOfViewUser = this.bizEventsViewUserRepository

List<BizEventsViewUser> 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<List<BizEventsViewUser>> retrievePaginatedList (String taxCode, Integer size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -281,8 +282,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<List<BizEventsViewUser>> argument = ArgumentCaptor.forClass(List.class);
verify(bizEventsViewUserRepository).saveAll(argument.capture());
assertEquals(Boolean.TRUE, argument.getValue().get(0).getHidden());
}

@Test
void transactionViewUserCartDisabled() {

List<BizEventsViewUser> 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<List<BizEventsViewUser>> argument = ArgumentCaptor.forClass(List.class);
verify(bizEventsViewUserRepository).saveAll(argument.capture());
argument.getValue().forEach(u -> assertEquals(Boolean.TRUE, u.getHidden()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading