Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRDP-233] feat: Add APIs to retrieve biz-event #29

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading