Skip to content

Commit

Permalink
PAGOPA-1494 extending coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoRuzzier committed Mar 12, 2024
1 parent 68a3808 commit 0410596
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,14 @@ private static boolean globalAndRelatedFilter(PaymentOptionMulti paymentOptionMu
* @return empty list if at least one element is not present, otherwise the full list
*/
private static List<CiBundle> filteredCiBundles(PaymentOptionMulti paymentOptionMulti, ValidBundle bundle) {
List<String> ciBundlesFiscalCodes = new ArrayList<>();
bundle.getCiBundleList().forEach(ciBundle -> ciBundlesFiscalCodes.add(ciBundle.getCiFiscalCode()));
boolean allCiBundlesPresent = paymentOptionMulti.getPaymentNotice().stream()
.anyMatch(paymentNoticeItem -> ciBundlesFiscalCodes.contains(paymentNoticeItem.getPrimaryCreditorInstitution()));
return allCiBundlesPresent ? bundle.getCiBundleList() : new ArrayList<>();
if(bundle.getCiBundleList() != null) {
List<String> ciBundlesFiscalCodes = new ArrayList<>();
bundle.getCiBundleList().forEach(ciBundle -> ciBundlesFiscalCodes.add(ciBundle.getCiFiscalCode()));
boolean allCiBundlesPresent = paymentOptionMulti.getPaymentNotice().stream()
.anyMatch(paymentNoticeItem -> ciBundlesFiscalCodes.contains(paymentNoticeItem.getPrimaryCreditorInstitution()));
return allCiBundlesPresent ? bundle.getCiBundleList() : new ArrayList<>();
}
return new ArrayList<>();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ void calculateMulti_amexPayment() throws IOException, JSONException {
}

@Test
@Order(25)
@Order(26)
void calculateMultiHighCommission() throws IOException, JSONException {
ValidBundle validBundle = TestUtil.getHighCommissionValidBundle();
Touchpoint touchpoint = TestUtil.getMockTouchpoints();
Expand All @@ -748,4 +748,25 @@ void calculateMultiHighCommission() throws IOException, JSONException {
String expected = TestUtil.readStringFromFile("responses/getFeesMultiHighCommission.json");
JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT);
}

@Test
@Order(27)
void calculateMultiFullCommission() throws IOException, JSONException {
ValidBundle validBundle = TestUtil.getMockValidBundle();
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(validBundle));

var paymentOption = TestUtil.readObjectFromFile("requests/getFeesMultiWrongEC.json", PaymentOptionMulti.class);
var result = calculatorService.calculateMulti(paymentOption, 10, true);
String actual = TestUtil.toJson(result);

String expected = TestUtil.readStringFromFile("responses/getFeesMultiWrongEC.json");
JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT);
}
}
28 changes: 28 additions & 0 deletions src/test/resources/requests/getFeesMultiWrongEC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"bin": "1005066",
"paymentMethod": "CP",
"touchpoint": "CHECKOUT",
"idPspList": [],
"paymentNotice": [
{
"primaryCreditorInstitution": "77777777778",
"paymentAmount": 70,
"transferList": [
{
"creditorInstitution": "77777777778",
"transferCategory": "TAX1"
}
]
},
{
"primaryCreditorInstitution": "77777777777",
"paymentAmount": 70,
"transferList": [
{
"creditorInstitution": "77777777777",
"transferCategory": "TAX1"
}
]
}
]
}
22 changes: 22 additions & 0 deletions src/test/resources/responses/getFeesMultiWrongEC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"belowThreshold": false,
"bundleOptions": [
{
"taxPayerFee": 1,
"actualPayerFee": 1,
"paymentMethod": "CP",
"touchpoint": "1",
"idBundle": "1",
"bundleName": "bundle1",
"bundleDescription": null,
"idsCiBundle": [],
"idPsp": "ABC",
"idChannel": "13212880150_07_ONUS",
"idBrokerPsp": null,
"onUs": true,
"abi": "14156",
"pspBusinessName": "psp business name 1",
"fees": []
}
]
}

0 comments on commit 0410596

Please sign in to comment.