Skip to content

Commit

Permalink
Merge pull request #94 from pagopa/PAGOPA-1607-java-17-migration
Browse files Browse the repository at this point in the history
feat: [PagoPA-1607] - java 17 migration
  • Loading branch information
pasqualespica authored Mar 22, 2024
2 parents 2847c97 + 07bfc00 commit 9edbea0
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ 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/maven-code-review@v1.4.2
uses: pagopa/github-actions-template/maven-code-review@v1.10.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
sonar_token: ${{ secrets.SONAR_TOKEN }}
project_key: ${{env.PROJECT_KEY}}
coverage_exclusions: "**/config/*,**/*Mock*,**/model/**,**/entity/*"
cpd_exclusions: "**/model/**,**/entity/*"
java_version: 17

smoke-test:
name: Smoke Test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Run Service on Docker
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#
# Build
#
FROM maven:3.8.4-jdk-11-slim as buildtime
FROM maven:3.9.3-amazoncorretto-17@sha256:4ab7db7bd5f95e58b0ba1346ff29d6abdd9b73e5fd89c5140edead8b037386ff AS buildtime
WORKDIR /build
COPY . .
RUN mvn clean package -Dmaven.test.skip=true

#
# Package stage
#
FROM --platform=linux/amd64 adoptopenjdk/openjdk16:alpine as builder
FROM --platform=linux/amd64 amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 as builder
COPY --from=buildtime /build/target/*.jar application.jar
RUN java -Djarmode=layertools -jar application.jar extract


FROM ghcr.io/pagopa/docker-base-springboot-openjdk11:v1.0.1@sha256:bbbe948e91efa0a3e66d8f308047ec255f64898e7f9250bdb63985efd3a95dbf
FROM ghcr.io/pagopa/docker-base-springboot-openjdk17:v1.1.0@sha256:6fa320d452fa22066441f1ef292d15eb06f944bc8bca293e1a91ea460d30a613
COPY --chown=spring:spring --from=builder dependencies/ ./
COPY --chown=spring:spring --from=builder snapshot-dependencies/ ./
# https://github.com/moby/moby/issues/37965#issuecomment-426853382
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ See the [OpenApi 3 here.](https://editor.swagger.io/?url=https://raw.githubuserc

## Technology Stack 📚

- Java 11
- Java 17
- Spring Boot
- Spring Web
- Feign Client
Expand Down
3 changes: 2 additions & 1 deletion integration-test/src/config/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ api_config_host=https://api.dev.platform.pagopa.it/apiconfig/auth/api/v1
gpd_host=https://api.dev.platform.pagopa.it/gpd/api/v1
nodo_host=https://api.dev.platform.pagopa.it/nodo

invalid_creditor_institution=00112233445
invalid_creditor_institution=00112233555
pspId=AGID_01
pspBrokerId=97735020584
pspChannelId=97735020584_03
pspName=AgID
pspFiscalCode=CFAGID_01
pspPassword=pwdpwdpwd
ip=api.dev.platform.pagopa.it
3 changes: 2 additions & 1 deletion integration-test/src/config/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ api_config_host=https://api.dev.platform.pagopa.it/apiconfig/auth/api/v1
gpd_host=https://api.dev.platform.pagopa.it/gpd/api/v1
nodo_host=https://api.dev.platform.pagopa.it/nodo

invalid_creditor_institution=00112233445
invalid_creditor_institution=00112233555
pspId=AGID_01
pspBrokerId=97735020584
pspChannelId=97735020584_03
pspName=AgID
pspFiscalCode=CFAGID_01
pspPassword=pwdpwdpwd
ip=api.dev.platform.pagopa.it
5 changes: 3 additions & 2 deletions integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ api_config_host=https://api.uat.platform.pagopa.it/apiconfig/auth/api/v1
gpd_host=https://api.uat.platform.pagopa.it/gpd/api/v1
nodo_host=https://api.uat.platform.pagopa.it/nodo

invalid_creditor_institution=00112233445
invalid_creditor_institution=00112233555
pspId=AGID_02
pspBrokerId=97735020584
pspChannelId=97735020584_05
pspName=PSP_Agid
pspPassword=pwd_AgID
pspPassword=pwd_AgID
ip=api.uat.platform.pagopa.it
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Feature: All about Activate Phase on Debt Position Payments workflow
And ApiConfig running
And the creditor institution "77777777777"
And the creditor institution broker "15376371009"
And the station "15376371009_01"
And the station "15376371009_01" for the broker "15376371009"
And if necessary, refresh the configuration and wait 30 seconds
And a valid debt position
And a proper verification of debt position

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Feature: All about Activate Phase on Debt Position Payments workflow
And ApiConfig running
And the creditor institution "77777777777"
And the creditor institution broker "15376371009"
And the station "15376371009_01"
And the station "15376371009_01" for the broker "15376371009"
And if necessary, refresh the configuration and wait 30 seconds
And a valid debt position

@GPDScenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Feature: All about Send Receipt Phase on Debt Position Payments workflow
And ApiConfig running
And the creditor institution "77777777777"
And the creditor institution broker "15376371009"
And the station "15376371009_01"
And the station "15376371009_01" for the broker "15376371009"
And if necessary, refresh the configuration and wait 30 seconds
And a valid debt position
And a proper verification of debt position
And a proper activation of debt position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Feature: All about Verify Phase on Debt Position Payments workflow
And ApiConfig running
And the creditor institution "77777777777"
And the creditor institution broker "15376371009"
And the station "15376371009_01"
And the station "15376371009_01" for the broker "15376371009"
And if necessary, refresh the configuration and wait 30 seconds
And a valid debt position

@GPDScenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,25 @@ function readCreditorInstitution(orgId) {
})
}

function createCreditorInstitution(body) {
return post(api_config_host + `/creditorinstitutions`, body, {
headers: {
"Ocp-Apim-Subscription-Key": process.env.SUBKEY
}
})
}


function readCreditorInstitutionIbans(orgId) {
return get(api_config_host + `/creditorinstitutions/${orgId}/ibans`, {
return get(api_config_host + `/creditorinstitutions/${orgId}/ibans/enhanced`, {
headers: {
"Ocp-Apim-Subscription-Key": process.env.SUBKEY
}
})
}

function createCreditorInstitutionIbans(orgId, body) {
return post(api_config_host + `/creditorinstitutions/${orgId}/ibans`, body, {
headers: {
"Ocp-Apim-Subscription-Key": process.env.SUBKEY
}
Expand All @@ -35,6 +52,14 @@ function readCreditorInstitutionBroker(brokerId) {
})
}

function createCreditorInstitutionBroker(body) {
return post(api_config_host + `/brokers`, body, {
headers: {
"Ocp-Apim-Subscription-Key": process.env.SUBKEY
}
})
}

function readStation(stationId) {
return get(api_config_host + `/stations/${stationId}`, {
headers: {
Expand All @@ -43,6 +68,14 @@ function readStation(stationId) {
})
}

function createStation(body) {
return post(api_config_host + `/stations`, body, {
headers: {
"Ocp-Apim-Subscription-Key": process.env.SUBKEY
}
})
}

function readECStationAssociation(stationId, orgId) {
return get(api_config_host + `/stations/${stationId}/creditorinstitutions/${orgId}`, {
headers: {
Expand All @@ -51,11 +84,33 @@ function readECStationAssociation(stationId, orgId) {
})
}

function createECStationAssociation(orgId, body) {
return post(api_config_host + `/creditorinstitutions/${orgId}/stations`, body, {
headers: {
"Ocp-Apim-Subscription-Key": process.env.SUBKEY
}
})
}

function refreshConfig() {
return get(api_config_host + `/refresh/config`, {
headers: {
"Ocp-Apim-Subscription-Key": process.env.SUBKEY
}
})
}

module.exports = {
apiConfigHealthCheck,
readCreditorInstitution,
readCreditorInstitutionBroker,
readCreditorInstitutionIbans,
readECStationAssociation,
readStation
readStation,
createCreditorInstitution,
createCreditorInstitutionIbans,
createCreditorInstitutionBroker,
createStation,
createECStationAssociation,
refreshConfig
}
99 changes: 86 additions & 13 deletions integration-test/src/step_definitions/support/logic/gpd_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const {
readCreditorInstitutionIbans,
readECStationAssociation,
readStation,
createCreditorInstitution,
createCreditorInstitutionIbans,
createCreditorInstitutionBroker,
createStation,
createECStationAssociation,
refreshConfig
} = require("../clients/api_config_client");
const {
createDebtPosition,
Expand All @@ -27,10 +33,17 @@ const {
buildSendPaymentOutcomeRequest,
buildSendRTRequest,
buildGetPaymentReq,
buildGetPaymentV2Req
buildGetPaymentV2Req,
buildApiConfigServiceCreationCIRequest,
buildApiConfigServiceCreationIbansRequest,
buildApiConfigServiceCreationBrokerRequest,
buildApiConfigServiceCreationStationRequest,
buildApiConfigServiceCreationECStationAssociation
} = require("../utility/request_builders");


let toRefresh = false;


async function assertPaymentTokenExistence(bundle) {
let paymentTokenRegExp = /<paymentToken>([a-z0-9]+)<\/paymentToken>/
Expand Down Expand Up @@ -62,26 +75,59 @@ async function executeDebtPositionVerificationAndActivation(bundle) {
}

async function readCreditorInstitutionBrokerInfo(bundle, brokerId) {
let status = 200;
let response = await readCreditorInstitutionBroker(brokerId);
assert.strictEqual(response.status, 200);
// if the test broker does not exist, it is created
if (response.status == 404){
toRefresh = true;
// new expected state check
status = 201;
let body = buildApiConfigServiceCreationBrokerRequest(brokerId);
response = await createCreditorInstitutionBroker(body);
}
assert.strictEqual(response.status, status);
bundle.brokerCode = brokerId;
}

async function readCreditorInstitutionInfo(bundle, creditorInstitutionId) {
readAndValidateCreditorInstitutionInfo(bundle, creditorInstitutionId, 200);
await readAndCreateCreditorInstitutionInfo(bundle, creditorInstitutionId, 200);
bundle.organizationCode = creditorInstitutionId;
readValidCreditorInstitutionInfo(bundle, creditorInstitutionId, 200);
await readValidCreditorInstitutionInfo(bundle, creditorInstitutionId, 200);
response = await readCreditorInstitutionIbans(bundle.organizationCode);
assert.ok(response.data.ibans[0] !== undefined);
bundle.debtPosition.iban = response.data.ibans[0].iban;
}

async function readStationInfo(bundle, stationId) {
// if there is no iban connected to the CI, it is created
if (response.data.ibans_enhanced.length == 0) {
toRefresh = true;
let body = buildApiConfigServiceCreationIbansRequest(new Date(new Date().setDate(new Date().getDate() + 7)).toISOString(),
new Date(new Date().setDate(new Date().getDate() + 1)).toISOString());
response = await createCreditorInstitutionIbans(bundle.organizationCode, body);
assert.strictEqual(response.status, 201);
bundle.debtPosition.iban = response.data.iban;
} else {
assert.ok(response.data.ibans_enhanced[0] !== undefined);
bundle.debtPosition.iban = response.data.ibans_enhanced[0].iban;
}
}

async function readStationInfo(bundle, stationId, brokerId) {
let status = 200;
let response = await readStation(stationId);
assert.strictEqual(response.status, 200);
// if the station does not exist, it is created
if (response.status == 404){
toRefresh = true;
status = 201;
const ip = process.env.ip;
let body = buildApiConfigServiceCreationStationRequest(stationId, brokerId, ip);
response = await createStation(body);
}
assert.strictEqual(response.status, status);
bundle.stationCode = stationId;
response = await readECStationAssociation(stationId, bundle.organizationCode);
assert.strictEqual(response.status, 200);
if (response.status == 404){
toRefresh = true;
body = buildApiConfigServiceCreationECStationAssociation(stationId);
response = await createECStationAssociation(bundle.organizationCode, body);
}
assert.ok(response.status == 201 || response.status == 200);
bundle.debtPosition.iuvPrefix = response.data.segregation_code < 10 ? `0${response.data.segregation_code}` : `${response.data.segregation_code}`;
}

Expand All @@ -90,7 +136,7 @@ async function readInvalidCreditorInstitutionInfo(bundle) {
}

async function readValidCreditorInstitutionInfo(bundle) {
readAndValidateCreditorInstitutionInfo(bundle, bundle.organizationCode, 200);
readAndCreateCreditorInstitutionInfo(bundle, bundle.organizationCode, 200);
}

async function readAndValidateCreditorInstitutionInfo(bundle, organizationCode, status) {
Expand All @@ -99,6 +145,20 @@ async function readAndValidateCreditorInstitutionInfo(bundle, organizationCode,
assert.strictEqual(response.status, status);
}

async function readAndCreateCreditorInstitutionInfo(bundle, organizationCode, status) {
bundle.debtPosition.fiscalCode = organizationCode;
let response = await readCreditorInstitution(bundle.debtPosition.fiscalCode);
// if the Creditor Institution does not exist, it is created
if (response.status == 404){
toRefresh = true;
// new expected state check
status = 201;
let body = buildApiConfigServiceCreationCIRequest(organizationCode);
response = await createCreditorInstitution(body);
}
assert.strictEqual(response.status, status);
}

async function sendActivatePaymentNoticeRequest(bundle) {
bundle.responseToCheck = await activatePaymentNotice(buildActivatePaymentNoticeRequest(bundle, bundle.debtPosition.fiscalCode));
}
Expand Down Expand Up @@ -126,6 +186,18 @@ async function sendGetPaymentV2Request(bundle) {
bundle.responseToCheck = await getPaymentV2(buildGetPaymentV2Req(bundle, bundle.debtPosition.fiscalCode));
}

// N.B.: even by launching the configuration refresh, if it was necessary to create a new IBAN, this will not be visible until the validity date is reached
async function refreshNodeConfig(timeout) {
if (toRefresh){
let response = await refreshConfig();
assert.strictEqual(response.status, 200);
toRefresh = false;
console.log("--> execution test is stopped for ["+timeout+"] seconds to update the cache. Please wait..");
await new Promise(resolve => setTimeout(resolve, timeout * 1000));
console.log("--> end of the wait, test execution resumes.");
}
}


module.exports = {
assertPaymentTokenExistence,
Expand All @@ -143,5 +215,6 @@ module.exports = {
sendSendPaymentOutcomeRequest,
sendVerifyPaymentNoticeRequest,
sendGetPaymentRequest,
sendGetPaymentV2Request
sendGetPaymentV2Request,
refreshNodeConfig
}
Loading

0 comments on commit 9edbea0

Please sign in to comment.