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: clearing issuers instead of exception PAGOPA-2388 #156

Merged
merged 3 commits into from
Nov 18, 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-afm-calculator
description: Microservice that handles calculation for pagoPA Advanced Fees Management
type: application
version: 2.47.0
appVersion: 2.10.33
version: 2.48.0
appVersion: 2.10.33-1-PAGOPA-2388
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-afm-calculator
tag: "2.10.33"
tag: "2.10.33-1-PAGOPA-2388"
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-afm-calculator
tag: "2.10.33"
tag: "2.10.33-1-PAGOPA-2388"
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-afm-calculator
tag: "2.10.33"
tag: "2.10.33-1-PAGOPA-2388"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-node-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.33"
"version": "2.10.33-1-PAGOPA-2388"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-node-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.33"
"version": "2.10.33-1-PAGOPA-2388"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-v1-dev-uat.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.33"
"version": "2.10.33-1-PAGOPA-2388"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.33"
"version": "2.10.33-1-PAGOPA-2388"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.33"
"version": "2.10.33-1-PAGOPA-2388"
},
"servers": [
{
Expand Down
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>calculator</artifactId>
<version>2.10.33</version>
<version>2.10.33-1-PAGOPA-2388</version>
<name>afm-calculator</name>
<description>Calculator Logic microservice for pagoPA AFM</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ private List<Transfer> calculateTaxPayerFee(
// is raised
// - the limit(2) operation is used to terminate as soon as two distinct ABI objects are found
if (isUniqueAbi(issuers)) {
throw new AppException(AppError.ISSUERS_BIN_WITH_DIFFERENT_ABI_ERROR, paymentOption.getBin());
// fix to solve the problem with overlapping ranges of some psps
issuers.clear();
//throw new AppException(AppError.ISSUERS_BIN_WITH_DIFFERENT_ABI_ERROR, paymentOption.getBin());
}

for (ValidBundle bundle : bundles) {
Expand Down Expand Up @@ -157,7 +159,9 @@ private List<it.gov.pagopa.afm.calculator.model.calculatormulti.Transfer> calcul
// is raised
// - the limit(2) operation is used to terminate as soon as two distinct ABI objects are found
if (isUniqueAbi(issuers)) {
throw new AppException(AppError.ISSUERS_BIN_WITH_DIFFERENT_ABI_ERROR, paymentOption.getBin());
// fix to solve the problem with overlapping ranges of some psps
issuers.clear();
//throw new AppException(AppError.ISSUERS_BIN_WITH_DIFFERENT_ABI_ERROR, paymentOption.getBin());
}

for (ValidBundle bundle : bundles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,27 +294,27 @@ void calculate_digitalStamp2() throws IOException, JSONException {
JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT);
}

@Test
@Order(9)
void calculate_BIN_with_different_ABI_error() throws IOException, JSONException {
Touchpoint touchpoint = TestUtil.getMockTouchpoints();
PaymentType paymentType = TestUtil.getMockPaymentType();

when(cosmosTemplate.find(any(CosmosQuery.class), any(), anyString()))
.thenReturn(
Collections.singleton(touchpoint),
Collections.singleton(paymentType),
Collections.singleton(TestUtil.getMockValidBundle()));

var paymentOption =
TestUtil.readObjectFromFile("requests/getFeesBINwithMultipleABI.json", PaymentOption.class);

AppException exception =
assertThrows(
AppException.class, () -> calculatorService.calculate(paymentOption, 10, true));

assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, exception.getHttpStatus());
}
// @Test
// @Order(9)
// void calculate_BIN_with_different_ABI_error() throws IOException, JSONException {
// Touchpoint touchpoint = TestUtil.getMockTouchpoints();
// PaymentType paymentType = TestUtil.getMockPaymentType();
//
// when(cosmosTemplate.find(any(CosmosQuery.class), any(), anyString()))
// .thenReturn(
// Collections.singleton(touchpoint),
// Collections.singleton(paymentType),
// Collections.singleton(TestUtil.getMockValidBundle()));
//
// var paymentOption =
// TestUtil.readObjectFromFile("requests/getFeesBINwithMultipleABI.json", PaymentOption.class);
//
// AppException exception =
// assertThrows(
// AppException.class, () -> calculatorService.calculate(paymentOption, 10, true));
//
// assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, exception.getHttpStatus());
// }

@Test
@Order(10)
Expand Down Expand Up @@ -595,27 +595,27 @@ void calculateMulti_digitalStamp2() throws IOException, JSONException {
JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT);
}

@Test
@Order(20)
void calculateMulti_BIN_with_different_ABI_error() throws IOException, JSONException {
Touchpoint touchpoint = TestUtil.getMockTouchpoints();
PaymentType paymentType = TestUtil.getMockPaymentType();

when(cosmosTemplate.find(any(CosmosQuery.class), any(), anyString()))
.thenReturn(
Collections.singleton(touchpoint),
Collections.singleton(paymentType),
Collections.singleton(TestUtil.getMockValidBundle()));

var paymentOption =
TestUtil.readObjectFromFile("requests/getFeesMultiBINwithMultipleABI.json", PaymentOptionMulti.class);

AppException exception =
assertThrows(
AppException.class, () -> calculatorService.calculateMulti(paymentOption, 10, true));

assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, exception.getHttpStatus());
}
// @Test
// @Order(20)
// void calculateMulti_BIN_with_different_ABI_error() throws IOException, JSONException {
// Touchpoint touchpoint = TestUtil.getMockTouchpoints();
// PaymentType paymentType = TestUtil.getMockPaymentType();
//
// when(cosmosTemplate.find(any(CosmosQuery.class), any(), anyString()))
// .thenReturn(
// Collections.singleton(touchpoint),
// Collections.singleton(paymentType),
// Collections.singleton(TestUtil.getMockValidBundle()));
//
// var paymentOption =
// TestUtil.readObjectFromFile("requests/getFeesMultiBINwithMultipleABI.json", PaymentOptionMulti.class);
//
// AppException exception =
// assertThrows(
// AppException.class, () -> calculatorService.calculateMulti(paymentOption, 10, true));
//
// assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, exception.getHttpStatus());
// }

@Test
@Order(21)
Expand Down