Skip to content

Commit

Permalink
Merge branch 'main' into allure-integration-reports
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoRuzzier authored Feb 3, 2025
2 parents f500086 + 90cb505 commit 63e47a3
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/anchore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3

- name: Build the Docker image
run: docker build . --file ${{ env.DOCKERFILE }} --tag localbuild/testimage:latest

- name: Run the Anchore scan action itself with GitHub Advanced Security code scanning integration enabled
uses: anchore/scan-action@v3
uses: anchore/scan-action@3343887d815d7b07465f6fdcd395bd66508d486a # v3
with:
image: "localbuild/testimage:latest"
acs-report-enable: true
fail-build: false
severity-cutoff: "high"
- name: Upload Anchore Scan Report
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2
if: always()
with:
sarif_file: results.sarif
10 changes: 5 additions & 5 deletions .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- name: Assign Me
# You may pin to the exact commit or the version.
uses: kentaro-m/[email protected]
uses: kentaro-m/auto-assign-action@746a3a558fdd0e061f612ec9f8ff1b8a19c1a115 # v1.2.1
with:
configuration-path: '.github/auto_assign.yml'

Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3

- name: Formatting
id: format
Expand All @@ -43,7 +43,7 @@ jobs:
path: .
fail-on-changes: false

- uses: actions/[email protected]
- uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
if: steps.format.outcome != 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -77,12 +77,12 @@ jobs:
runs-on: ubuntu-latest
name: Check Size
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
fetch-depth: 0

- name: Check Size
uses: actions/[email protected]
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
env:
IGNORED_FILES: openapi-v1.json, openapi-v2.json, openapi-node-v1.json, openapi-node-v2.json
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Code Review
uses: pagopa/github-actions-template/[email protected]
uses: pagopa/github-actions-template/maven-code-review@5a544cfcc87edacde3391e4fb70228194f90ec63 # v1.10.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
sonar_token: ${{ secrets.SONAR_TOKEN }}
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
run: echo "$GITHUB_CONTEXT"

- name: Delete Previous deployments
uses: actions/github-script@v6
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
env:
SHA_HEAD: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha}}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
persist-credentials: false

# from https://github.com/pagopa/opex-dashboard-azure-action/
- uses: pagopa/[email protected]
- uses: pagopa/opex-dashboard-azure-action@ece3bc2b133be74cabb50aec14cdb9b8051b886f # v1.1.2
with:
environment: ${{ matrix.environment }}
api-name: ${{ matrix.product }}/${{ matrix.version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
steps:
- name: Report Status
if: ${{ inputs.notify }}
uses: ravsamhq/notify-slack-action@v2
uses: ravsamhq/notify-slack-action@be814b201e233b2dc673608aa46e5447c8ab13f2 # v2
with:
status: ${{ needs.integration_test.result }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -139,7 +139,7 @@ jobs:
run: echo "$GITHUB_CONTEXT"

- name: Delete Previous deployments
uses: actions/github-script@v6
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
env:
SHA_HEAD: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha}}
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
steps:
- name: Make Release
id: release
uses: pagopa/github-actions-template/[email protected]
uses: pagopa/github-actions-template/maven-release@d91a1fd0b913c9830589be5d86cdb71c90813fae # v1.5.4
with:
semver: ${{ needs.setup.outputs.semver }}
github_token: ${{ secrets.BOT_TOKEN_GITHUB }}
Expand All @@ -115,7 +115,7 @@ jobs:
steps:
- name: Build and Push
id: semver
uses: pagopa/github-actions-template/[email protected]
uses: pagopa/github-actions-template/ghcr-build-push@d91a1fd0b913c9830589be5d86cdb71c90813fae # v1.5.4
with:
branch: ${{ github.ref_name}}
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -138,7 +138,7 @@ jobs:
steps:
- name: Report Status
if: ${{ needs.setup.outputs.environment == 'prod' }}
uses: ravsamhq/notify-slack-action@v2
uses: ravsamhq/notify-slack-action@be814b201e233b2dc673608aa46e5447c8ab13f2 # v2
with:
status: ${{ needs.deploy_aks.result }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/update_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
if: ${{ contains(github.event.comment.body, 'update_code') }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
ref: ${{ github.ref }}
token: ${{ secrets.BOT_TOKEN_GITHUB }}

- name: Set up JDK 17
uses: actions/setup-java@v1
uses: actions/setup-java@b6e674f4b717d7b0ae3baee0fbe79f498905dfde # v1
with:
java-version: 17

Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
if: ${{ always() && contains(needs.*.result, 'failure') }}
steps:
- name: Notify if Failure
uses: actions/[email protected]
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2

# prepare openapi template for infra repo
- run: |
Expand Down
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.52.0
appVersion: 2.10.36-1-allure-integration-reports
version: 2.53.0
appVersion: 2.10.38
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.36-1-allure-integration-reports"
tag: "2.10.38"
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.36-1-allure-integration-reports"
tag: "2.10.38"
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.36-1-allure-integration-reports"
tag: "2.10.38"
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.36-1-allure-integration-reports"
"version": "2.10.38"
},
"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.36-1-allure-integration-reports"
"version": "2.10.38"
},
"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.36-1-allure-integration-reports"
"version": "2.10.38"
},
"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.36-1-allure-integration-reports"
"version": "2.10.38"
},
"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.36-1-allure-integration-reports"
"version": "2.10.38"
},
"servers": [
{
Expand Down
4 changes: 2 additions & 2 deletions performance-test/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.3'
services:
k6:
image: grafana/k6
image: grafana/k6@sha256:de89ab0b01659d962e8efcf2fb34893187179d9edbef9f4344641702c02d0852
container_name: k6
volumes:
- '${PWD}/src:/scripts'
Expand All @@ -16,7 +16,7 @@ services:
- nginx

nginx:
image: nginx
image: nginx@sha256:0a399eb16751829e1af26fea27b20c3ec28d7ab1fb72182879dcae1cca21206a
container_name: nginx
volumes:
- '${PWD}/nginx/nginx.conf:/etc/nginx/nginx.conf'
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.36-1-allure-integration-reports</version>
<version>2.10.38</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
@@ -1,14 +1,12 @@
package it.gov.pagopa.afm.calculator.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.*;

@AllArgsConstructor
@NoArgsConstructor
@Data
@ToString
@Builder
public class TransferListItem {
private String creditorInstitution;
private String transferCategory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public List<String> getTransferCategoryList(PaymentOption paymentOption) {
return paymentOption.getTransferList() != null
? paymentOption.getTransferList().parallelStream()
.map(TransferListItem::getTransferCategory)
.map(UtilityComponent::getTaxonomyValue)
.distinct()
.collect(Collectors.toList())
: null;
Expand All @@ -69,9 +70,10 @@ public List<String> getTransferCategoryList(PaymentOptionMulti paymentOptionMult
List<TransferListItem> transferList = new ArrayList<>();
paymentOptionMulti.getPaymentNotice().forEach(paymentNoticeItem -> transferList.addAll(paymentNoticeItem.getTransferList()));
log.debug("getTransferCategoryList");
return transferList != null
return !transferList.isEmpty()
? transferList.parallelStream()
.map(TransferListItem::getTransferCategory)
.map(UtilityComponent::getTaxonomyValue)
.distinct()
.collect(Collectors.toList())
: null;
Expand All @@ -93,6 +95,7 @@ public List<String> getPrimaryTransferCategoryList(
? paymentOption.getTransferList().parallelStream()
.filter(elem -> primaryCreditorInstitution.equals(elem.getCreditorInstitution()))
.map(TransferListItem::getTransferCategory)
.map(UtilityComponent::getTaxonomyValue)
.distinct()
.collect(Collectors.toList())
: new ArrayList<>();
Expand All @@ -114,8 +117,25 @@ public List<String> getPrimaryTransferCategoryListMulti(
? paymentNoticeItem.getTransferList().parallelStream()
.filter(elem -> primaryCreditorInstitution.equals(elem.getCreditorInstitution()))
.map(TransferListItem::getTransferCategory)
.map(UtilityComponent::getTaxonomyValue)
.distinct()
.collect(Collectors.toList())
: new ArrayList<>();
}


/**
* Extracts and returns the taxonomy value from the given element string.
* examples:
* 9/9182ABC/ -> 9182ABC
* 9182ABC -> 9182ABC
*
* @param elem the input string containing taxonomy information, expected to be in the format "category/taxonomy".
* @return the taxonomy part of the input string if available, otherwise returns the original string.
*/
private static String getTaxonomyValue(String elem) {
String[] split = elem.split("/");
return split.length > 1 ? split[1] : split[0];
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package it.gov.pagopa.afm.calculator.service;

import it.gov.pagopa.afm.calculator.model.PaymentOption;
import it.gov.pagopa.afm.calculator.model.TransferListItem;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
class UtilityComponentTest {

@Autowired
UtilityComponent utilityComponent;


@Test
void getPrimaryTransferCategoryListMulti() {
var res = utilityComponent.getTransferCategoryList(PaymentOption.builder()
.transferList(List.of(TransferListItem.builder()
.transferCategory("9/123ABC987")
.build()))
.build());
assertEquals("123ABC987", res.get(0));
}
}

0 comments on commit 63e47a3

Please sign in to comment.