Skip to content

Commit

Permalink
feat: [PagoPA-2083] Api integration test (#92)
Browse files Browse the repository at this point in the history
* [PAGOPA-2083] disable API: updated integration test

* [PAGOPA-2083] disable API: fix all integration test

* fix

* fix

* run docker

* Bump to version 0.1.57-1-PAGOPA-2083-disable-API-integration-test [skip ci]

* Bump to version 0.1.57-2-PAGOPA-2083-disable-API-integration-test [skip ci]

* Merge branch 'PAGOPA-2083-disable-API-integration-test' of
https://github.com/pagopa/pagopa-biz-events-service into
PAGOPA-2083-disable-API-integration-test

* [PAGOPA-2083] disable API: fix all integration test

* fix

* fix

* run docker

* Bump to version 0.1.57-1-PAGOPA-2083-disable-API-integration-test [skip ci]

* Bump to version 0.1.57-2-PAGOPA-2083-disable-API-integration-test [skip ci]

* Merge branch 'PAGOPA-2083-disable-API-integration-test' of
https://github.com/pagopa/pagopa-biz-events-service into
PAGOPA-2083-disable-API-integration-test

---------

Co-authored-by: pagopa-github-bot <[email protected]>
Co-authored-by: aacitelli <[email protected]>
Co-authored-by: pasqualespica <[email protected]>
Co-authored-by: Jacopo Carlini <[email protected]>
  • Loading branch information
5 people authored Sep 18, 2024
1 parent 46d6067 commit 84e6faa
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ jobs:
shell: bash
id: run_integration_test
run: |
export SUBKEY=${{ secrets.SUBKEY }}
export CANARY=${{ inputs.canary }}
export SUBKEY=${{ secrets.SUBKEY }}
export CANARY=${{ inputs.canary }}
export CUCUMBER_PUBLISH_TOKEN=${{ secrets.CUCUMBER_PUBLISH_TOKEN }}
export COSMOS_DB_PRIMARY_KEY=${{ secrets.COSMOS_DB_PRIMARY_KEY }}
export COSMOS_DB_CONN_STRING=${{ secrets.COSMOS_DB_CONN_STRING }}
export COSMOS_DB_CONN_STRING='${{ secrets.COSMOS_DB_CONN_STRING }}'
cd ./integration-test
chmod +x ./run_integration_test.sh
./run_integration_test.sh local
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
container_app_environment_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_NAME }}
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} # RG of the runner
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
# self_hosted_runner_image_tag: "v1.6.0"
self_hosted_runner_image_tag: "latest"

integration_test:
needs: [ create_runner ]
Expand Down
3 changes: 2 additions & 1 deletion docker/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ docker compose -p "${stack_name}" up -d --remove-orphans --force-recreate --buil
printf 'Waiting for the service'
attempt_counter=0
max_attempts=50
until [ $(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/info) -ne 200 ]; do
# until [ $(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/info) -ne 200 ]; do
until $(curl --output /dev/null --silent --head --fail http://localhost:8080/info); do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "Max attempts reached"
exit 1
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-biz-events-service
description: Microservice for exposing REST APIs about payment receipts.
type: application
version: 0.80.0
appVersion: 0.1.57
version: 0.82.0
appVersion: 0.1.57-2-PAGOPA-2083-disable-API-integration-test
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.57"
tag: "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
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.57"
tag: "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
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.57"
tag: "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion integration-test/src/config/.env.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BIZ_EVENTS_SERVICE_HOST=https://api.dev.platform.pagopa.it/bizevents/service/v1/
BIZ_EVENTS_HELPDESK_HOST=https://api.dev.platform.pagopa.it/bizevents/helpdesk/v1/
BIZ_EVENTS_TRXSRV_HOST=https://api.dev.platform.pagopa.it/bizevents/tx-service/v1/
BIZ_EVENTS_LAPSRV_HOST=https://api.dev.platform.pagopa.it/bizevents/notices-service/v1/
COSMOS_DB_URI=https://pagopa-d-weu-bizevents-ds-cosmos-account.documents.azure.com:443/
COSMOS_DB_NAME=db
COSMOS_DB_CONTAINER_NAME=biz-events
Expand Down
2 changes: 1 addition & 1 deletion integration-test/src/config/.env.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BIZ_EVENTS_SERVICE_HOST=<localhost>
BIZ_EVENTS_HELPDESK_HOST=<localhost>
BIZ_EVENTS_TRXSRV_HOST=<localhost>
BIZ_EVENTS_LAPSRV_HOST=<localhost>
COSMOS_DB_URI=https://pagopa-d-weu-bizevents-ds-cosmos-account.documents.azure.com:443/
COSMOS_DB_NAME=db
COSMOS_DB_CONTAINER_NAME=biz-events
Expand Down
2 changes: 1 addition & 1 deletion integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BIZ_EVENTS_SERVICE_HOST=https://api.uat.platform.pagopa.it/bizevents/service/v1/
BIZ_EVENTS_HELPDESK_HOST=https://api.uat.platform.pagopa.it/bizevents/helpdesk/v1/
BIZ_EVENTS_TRXSRV_HOST=https://api.uat.platform.pagopa.it/bizevents/tx-service/v1/
BIZ_EVENTS_LAPSRV_HOST=https://api.uat.platform.pagopa.it/bizevents/notices-service/v1/
COSMOS_DB_URI=https://pagopa-u-weu-bizevents-ds-cosmos-account.documents.azure.com:443/
COSMOS_DB_NAME=db
COSMOS_DB_CONTAINER_NAME=biz-events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { get, post } = require("./common");

const bizevents_service_host = process.env.BIZ_EVENTS_SERVICE_HOST;
const bizevents_helpdesk_host = process.env.BIZ_EVENTS_HELPDESK_HOST;
const bizevents_trxsrv_host = process.env.BIZ_EVENTS_TRXSRV_HOST;
const bizevents_trxsrv_host = process.env.BIZ_EVENTS_LAPSRV_HOST;


// is the same 4all
Expand All @@ -25,21 +25,21 @@ function getBizEventByOrgFiscalCodeAndIuv(organizationfiscalcode, iuv) {
return get(bizevents_helpdesk_host + `events/organizations/${organizationfiscalcode}/iuvs/${iuv}`, {})
}

// >>> BIZ_EVENTS_TRXSRV_HOST
// >>> BIZ_EVENTS_LAPSRV_HOST
function getTransactionListForUserWithFiscalCode(fiscalcode) {
return get(bizevents_trxsrv_host + `transactions?start=0&size=10`, {
return get(bizevents_trxsrv_host + `paids?size=10`, {
"x-fiscal-code": fiscalcode
})
}

function getTransactionWithIdForUserWithFiscalCode(id, fiscalcode) {
return get(bizevents_trxsrv_host + `transactions/${id}`, {
return get(bizevents_trxsrv_host + `paids/${id}`, {
"x-fiscal-code": fiscalcode
})
}

function disableTransactionWithIdForUserWithFiscalCode(id, fiscalcode) {
return post(bizevents_trxsrv_host + `transactions/${id}/disable`,"", {
return post(bizevents_trxsrv_host + `paids/${id}/disable`,"", {
"x-fiscal-code": fiscalcode
})
}
Expand Down
1 change: 0 additions & 1 deletion integration-test/src/step_definitions/support/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function post(url, body, headers) {
return res;
})
.catch(error => {
console.log(error)
return error.response;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ After(async function () {
await deleteDocumentFromViewCartDatastore(viewCart.id, viewCart.transactionId);
}
}

responseToCheck = null;
receipt = null;
bizEvent = null;
Expand Down Expand Up @@ -178,21 +178,21 @@ Then('the user gets the status code {int}', (status) => {
})

Then('the user gets {int} transactions', (totalTransactions) => {
assert.strictEqual(responseToCheck.data.length, totalTransactions);
assert.strictEqual(responseToCheck.data.notices.length, totalTransactions);
})

Then('the transactions with cart items {string} for taxCode {string} have the correct amount and subject', (isCart, taxCode) => {
for (let transaction of responseToCheck.data) {
for (let transaction of responseToCheck.data.notices) {
let totalAmount = 0;
for(let viewCart of viewCartList.filter(el => el.transactionId == transaction.transactionId && (transaction?.payer?.taxCode === taxCode || el?.debtor?.taxCode === taxCode))){
for(let viewCart of viewCartList.filter(el => el.transactionId == transaction.eventId)){
totalAmount += viewCart.amount;
if(isCart == "true"){
assert.notStrictEqual(transaction.payeeName, viewCart.payee.name);
} else {
assert.strictEqual(transaction.payeeName, viewCart.payee.name);
}
}
assert.strictEqual(transaction.amount, `${totalAmount},00`);
assert.strictEqual(transaction.amount, `${totalAmount}.00`);

}
})
Expand All @@ -211,12 +211,13 @@ When('the user with taxCode {string} disables the transaction with id {string}',
})

Then('the user with tax code {string} gets the transaction detail with id {string} and it has the correct amount', (taxCode, id) => {
let infoTransaction = responseToCheck.data.infoTransaction;
assert.strictEqual(infoTransaction.transactionId, id);
let infoNotice = responseToCheck.data.infoNotice;
assert.strictEqual(infoNotice.eventId, id);

let totalAmount = 0;
for(let viewCart of viewCartList.filter(el => el.transactionId == infoTransaction.transactionId && (infoTransaction?.payer?.taxCode === taxCode || el?.debtor?.taxCode === taxCode))){
for(let viewCart of viewCartList.filter(el => el.transactionId == infoNotice.eventId && (infoNotice?.payer?.taxCode === taxCode || el?.debtor?.taxCode === taxCode))){
totalAmount += viewCart.amount;
}
assert.strictEqual(infoTransaction.amount, `${totalAmount},00`);

assert.strictEqual(infoNotice.amount, `${totalAmount}.00`);
})
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.57"
"version": "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
},
"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.57"
"version": "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
},
"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.57"
"version": "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
},
"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.57"
"version": "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion 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.57"
"version": "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_io_patch_lap.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.57"
"version": "0.1.57-2-PAGOPA-2083-disable-API-integration-test"
},
"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>bizeventsservice</artifactId>
<version>0.1.57</version>
<version>0.1.57-2-PAGOPA-2083-disable-API-integration-test</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 @@ -68,15 +68,7 @@ public TransactionListResponse getTransactionList(String taxCode, Boolean isPaye
final Sort sort = Sort.by(Sort.Direction.fromString(direction), columnName);
final CosmosPageRequest pageRequest = new CosmosPageRequest(0, size, continuationToken, sort);
final Page<BizEventsViewUser> page = this.bizEventsViewUserRepository.getBizEventsViewUserByTaxCode(taxCode, isPayer, isDebtor, pageRequest);
Set<String> set = new HashSet<>(page.getContent().size());

List<BizEventsViewUser> listOfViewUser = page.getContent().stream()
.sorted(Comparator.comparing(BizEventsViewUser::getIsDebtor, Comparator.reverseOrder()))
.filter(p -> set.add(p.getTransactionId()))
.toList()
.stream()
.sorted(Comparator.comparing(BizEventsViewUser::getTransactionDate, Comparator.reverseOrder()))
.toList();
List<BizEventsViewUser> listOfViewUser = page.getContent();

if (listOfViewUser.isEmpty()) {
throw new AppException(AppError.VIEW_USER_NOT_FOUND_WITH_TAX_CODE_AND_FILTER, taxCode, isPayer, isDebtor);
Expand Down

0 comments on commit 84e6faa

Please sign in to comment.