generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PRDP-318] feat: Setup integration test for transaction APIs (#31)
* [PRDP-318] setup integration test for transaction APIs * [PRDP-318] added secret for integration test in identity * [PRDP-318] added integration test for cart transactions * [PRDP-318] fix integration tests * [PRDP-318] fixed integration test parameters * [PRDP-318] format code --------- Co-authored-by: giomella <gioele.mella@emeal.nttdata.com>
- Loading branch information
1 parent
af36a79
commit 931dceb
Showing
11 changed files
with
313 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ hs_err_pid* | |
# Project files | ||
/target/ | ||
**/node_modules | ||
yarn.lock | ||
|
||
# Terraform | ||
**/.terraform/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
integration-test/src/step_definitions/support/biz_events_cosmosdb_client.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { CosmosClient } = require("@azure/cosmos"); | ||
const { createEvent } = require("./common"); | ||
|
||
const cosmos_db_conn_string = process.env.COSMOS_DB_CONN_STRING; | ||
const databaseId = process.env.COSMOS_DB_NAME; // es. db | ||
const containerId = process.env.COSMOS_DB_CONTAINER_NAME; // es. biz-events | ||
|
||
const client = new CosmosClient(cosmos_db_conn_string); | ||
const container = client.database(databaseId).container(containerId); | ||
|
||
async function getDocumentByIdFromBizEventsDatastore(id) { | ||
return await container.items | ||
.query({ | ||
query: "SELECT * from c WHERE c.id=@id", | ||
parameters: [{ name: "@id", value: id }] | ||
}) | ||
.fetchAll(); | ||
} | ||
|
||
async function createDocumentInBizEventsDatastore(event) { | ||
try { | ||
return await container.items.create(event); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
} | ||
|
||
async function deleteDocumentFromBizEventsDatastore(id) { | ||
try { | ||
return await container.item(id, id).delete(); | ||
} catch (error) { | ||
if (error.code !== 404) { | ||
console.log(error) | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
getDocumentByIdFromBizEventsDatastore, createDocumentInBizEventsDatastore, deleteDocumentFromBizEventsDatastore | ||
} |
28 changes: 21 additions & 7 deletions
28
integration-test/src/step_definitions/support/bizeventservice_client.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,40 @@ | ||
const {get} = require("./common"); | ||
const { get } = require("./common"); | ||
|
||
const bizevents_service_host = process.env.BIZ_EVENTS_SERVICE_HOST; | ||
|
||
function healthCheckInfo() { | ||
return get(bizevents_service_host+`info`, {}) | ||
return get(bizevents_service_host + `info`, {}) | ||
} | ||
|
||
function getOrganizationReceipt(organizationfiscalcode, iur, iuv) { | ||
return get(bizevents_service_host+`organizations/${organizationfiscalcode}/receipts/${iur}/paymentoptions/${iuv}`, {}) | ||
return get(bizevents_service_host + `organizations/${organizationfiscalcode}/receipts/${iur}/paymentoptions/${iuv}`, {}) | ||
} | ||
|
||
function getBizEventById(id) { | ||
return get(bizevents_service_host+`events/${id}`, {}) | ||
return get(bizevents_service_host + `events/${id}`, {}) | ||
} | ||
|
||
function getBizEventByOrgFiscalCodeAndIuv(organizationfiscalcode, iuv) { | ||
return get(bizevents_service_host+`events/organizations/${organizationfiscalcode}/iuvs/${iuv}`, {}) | ||
return get(bizevents_service_host + `events/organizations/${organizationfiscalcode}/iuvs/${iuv}`, {}) | ||
} | ||
|
||
function getTransactionListForUserWithFiscalCode(fiscalcode) { | ||
return get(bizevents_service_host + `transactions?start=0&size=10`, { | ||
"x-fiscal-code": fiscalcode | ||
}) | ||
} | ||
|
||
function getTransactionWithIdForUserWithFiscalCode(id, fiscalcode, isCart) { | ||
return get(bizevents_service_host + `transactions/${id}?isCart=${isCart}`, { | ||
"x-fiscal-code": fiscalcode | ||
}) | ||
} | ||
|
||
module.exports = { | ||
healthCheckInfo, | ||
healthCheckInfo, | ||
getOrganizationReceipt, | ||
getBizEventById, | ||
getBizEventByOrgFiscalCodeAndIuv | ||
getBizEventByOrgFiscalCodeAndIuv, | ||
getTransactionListForUserWithFiscalCode, | ||
getTransactionWithIdForUserWithFiscalCode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.