Skip to content

Commit

Permalink
[PRDP-233] feat: Add APIs to retrieve biz-event (#29)
Browse files Browse the repository at this point in the history
* [PRDP-33] added new APIs to retrieve biz-event and updated unit tests

* [PRDP-233] updated openapi.json

* [PRDP-233] added integration test for new APIs

---------

Co-authored-by: giomella <[email protected]>
  • Loading branch information
gioelemella and giomella authored Dec 5, 2023
1 parent 82cf546 commit 1a44891
Show file tree
Hide file tree
Showing 15 changed files with 1,031 additions and 115 deletions.
14 changes: 14 additions & 0 deletions integration-test/src/features/organizationsreceipt.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ Feature: All about Organizations Receipt
Then the organization gets the status code 200
And the details of the receipt are returned to the organization with receiptId "123456789"
And the Biz-Event to test with id "123456789" is removed

Scenario: An operator asks for a Biz-Event with fiscal code PA and iuv
Given Biz-Event to test with id "123456789" and save it on Cosmos DB
When the operator asks for a Biz-Event with fiscal code PA "fiscalCode-123456789" and iuv "iuv-123456789"
Then the operator gets the status code 200
And the details of the Biz-Event are returned to the operator with id "123456789"
And the Biz-Event to test with id "123456789" is removed

Scenario: An operator asks for a Biz-Event id
Given Biz-Event to test with id "123456789" and save it on Cosmos DB
When the operator asks for a Biz-Event with id "123456789"
Then the operator gets the status code 200
And the details of the Biz-Event are returned to the operator with id "123456789"
And the Biz-Event to test with id "123456789" is removed
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ function getOrganizationReceipt(organizationfiscalcode, iur, iuv) {
return get(bizevents_service_host+`organizations/${organizationfiscalcode}/receipts/${iur}/paymentoptions/${iuv}`, {})
}

function getBizEventById(id) {
return get(bizevents_service_host+`events/${id}`, {})
}

function getBizEventByOrgFiscalCodeAndIuv(organizationfiscalcode, iuv) {
return get(bizevents_service_host+`events/organizations/${organizationfiscalcode}/iuvs/${iuv}`, {})
}

module.exports = {
healthCheckInfo,
getOrganizationReceipt
getOrganizationReceipt,
getBizEventById,
getBizEventByOrgFiscalCodeAndIuv
}
2 changes: 1 addition & 1 deletion integration-test/src/step_definitions/support/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require("axios");
const cryptojs = require("crypto-js");

axios.defaults.headers.common['Ocp-Apim-Subscription-Key'] = process.env.SUBKEY // for all requests
axios.defaults.headers.common['Ocp-Apim-Subscription-Key'] = process.env.SUBKEY || "";// for all requests
if (process.env.CANARY) {
axios.defaults.headers.common['X-Canary'] = 'canary' // for all requests
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
const assert = require('assert')
const {Given, When, Then, setDefaultTimeout} = require('@cucumber/cucumber')
const {getOrganizationReceipt} = require("./bizeventservice_client");
const {Given, When, Then, setDefaultTimeout, After} = require('@cucumber/cucumber')
const {getOrganizationReceipt, getBizEventById, getBizEventByOrgFiscalCodeAndIuv} = require("./bizeventservice_client");
const {createDocument, deleteDocument} = require("./cosmosdb_client");

let responseToCheck;
let receipt;
let bizEvent;

setDefaultTimeout(360 * 1000);

// After each Scenario
After(async function () {
// remove event
responseToCheck = null;
receipt = null;
bizEvent = null;
});


// Given
Given('Biz-Event to test with id {string} and save it on Cosmos DB', async function (id) {
Expand All @@ -27,6 +36,17 @@ When('the organization asks for a receipt with fiscal code PA {string} and iur {
receipt = responseToCheck.data;
});

When('the operator asks for a Biz-Event with fiscal code PA {string} and iuv {string}', async function (organizationFiscalCode, iuv) {
responseToCheck = await getBizEventByOrgFiscalCodeAndIuv(organizationFiscalCode, iuv);
// save data
bizEvent = responseToCheck.data;
});

When('the operator asks for a Biz-Event with id {string}', async function (id) {
responseToCheck = await getBizEventById(id);
// save data
bizEvent = responseToCheck.data;
});


// Then
Expand All @@ -35,12 +55,19 @@ Then('the organization gets the status code {int}', async function (status) {
});

Then('the details of the receipt are returned to the organization with receiptId {string}', async function (receiptId) {
assert.strictEqual(receipt.receiptId, receiptId);
assert.strictEqual(receipt.receiptId, receiptId);
});

Then('the Biz-Event to test with id {string} is removed', async function (id) {
//post condition - delete test data
//post condition - delete test data
responseToCheck = await deleteDocument(id);
assert.strictEqual(responseToCheck.status, 204);
});

Then('the operator gets the status code {int}', async function (status) {
assert.strictEqual(responseToCheck.status, status);
});

Then('the details of the Biz-Event are returned to the operator with id {string}', async function (id) {
assert.strictEqual(bizEvent.id, id);
});
Loading

0 comments on commit 1a44891

Please sign in to comment.