generated from pagopa/template-java-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.
- Loading branch information
1 parent
863d06c
commit ce3b878
Showing
7 changed files
with
207 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Feature: All about Organizations | ||
|
||
Scenario: An organization creates an enrollment | ||
Given the organization "777777" | ||
When the organization enrolls in the service "service-1" | ||
Then the organization is enrolled in the service | ||
|
||
Scenario: An organization tries to create an enrollment, but service not found | ||
Given the organization "777777" | ||
When the organization enrolls in the service "service-not-found" | ||
Then the organization gets the status code 404 | ||
|
||
Scenario: An organization deletes an enrollment | ||
Given the organization "777777" with the service "service-1" | ||
When the organization deletes the service "service-1" | ||
Then the organization isn't enrolled in the service |
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,17 @@ | ||
Feature: All about Services | ||
|
||
Scenario: success services list | ||
Given some services in the DB | ||
When the client get all services | ||
Then the client receives status code of 200 | ||
And the client retrieves the list of services | ||
|
||
Scenario: get service with success | ||
Given some services in the DB | ||
When the client get service "d" | ||
Then the client receives status code of 200 | ||
|
||
Scenario: service not found | ||
Given no services in the DB | ||
When the client get service 1 | ||
Then the client receives status code of 404 |
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,55 @@ | ||
const axios = require("axios"); | ||
const assert = require("assert"); | ||
|
||
const gps_host = 'http://localhost:9090'; | ||
|
||
function get(url) { | ||
return axios.get(gps_host + url) | ||
.then(res => { | ||
return res; | ||
}) | ||
.catch(error => { | ||
assert.fail(error); | ||
}); | ||
} | ||
|
||
function post(url, body) { | ||
return axios.post(gps_host + url, body) | ||
.then(res => { | ||
return res; | ||
}) | ||
.catch(error => { | ||
assert.fail(error); | ||
}); | ||
} | ||
|
||
function put(url, body) { | ||
return axios.put(gps_host + url, body) | ||
.then(res => { | ||
return res; | ||
}) | ||
.catch(error => { | ||
assert.fail(error); | ||
}); | ||
} | ||
|
||
|
||
function del(url) { | ||
return axios.delete(gps_host + url) | ||
.then(res => { | ||
return res; | ||
}) | ||
.catch(error => { | ||
assert.fail(error); | ||
}); | ||
} | ||
|
||
function randomIban() { | ||
return "IT" + (Math.round(Math.random() * 89999999) + 10000000); | ||
} | ||
|
||
function randomName() { | ||
return "Name_" + Math.floor(Math.random() * 100); | ||
} | ||
|
||
module.exports = {get, post, put, del, randomIban, randomName} |
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,49 @@ | ||
const assert = require('assert') | ||
const {Given, When, Then} = require('@cucumber/cucumber') | ||
const {post, get, randomIban, randomName} = require("./common"); | ||
|
||
let responseToCheck; | ||
let organization; | ||
let enrollments; | ||
|
||
|
||
// Given | ||
|
||
Given('the organization {string}', async function (idOrg) { | ||
responseToCheck = await post(`/organizations/${idOrg}`, {companyName: idOrg}); | ||
assert.strictEqual(responseToCheck.status, 201); | ||
organization = responseToCheck.data; | ||
organization.code = idOrg; | ||
}); | ||
|
||
Given('the organization {string} with the service {string}', async function (idOrg, idService) { | ||
responseToCheck = await post(`/organizations/${idOrg}`, {companyName: idOrg, | ||
enrollments: [{ | ||
serviceId: idService, | ||
iban: randomIban(), | ||
officeName: randomName() | ||
}]}); | ||
assert.strictEqual(responseToCheck.status, 201); | ||
organization = responseToCheck.data; | ||
organization.code = idOrg; | ||
}); | ||
|
||
|
||
// When | ||
When('the organization enrolls in the service {string}', async function (idService) { | ||
responseToCheck = await post(`/organizations/${organization.code}/services/${idService}`, { | ||
iban: randomIban(), | ||
officeName: randomName() | ||
}); | ||
assert.strictEqual(responseToCheck.status, 201); | ||
enrollments = responseToCheck.data; | ||
}); | ||
|
||
|
||
// Then | ||
|
||
Then(/^the organization is enrolled in the service$/, async function () { | ||
responseToCheck = await get(`/organizations/${organization.code}`); | ||
assert.strictEqual(responseToCheck.status, 200); | ||
assert.deepStrictEqual(responseToCheck.data.enrollments, enrollments) | ||
}); |
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,36 @@ | ||
const assert = require('assert') | ||
const {Given, When, Then} = require('@cucumber/cucumber') | ||
const {get} = require("./common"); | ||
|
||
let responseToCheck; | ||
let service; | ||
|
||
|
||
// Given | ||
|
||
Given('some services in the DB', function () { | ||
// TODO | ||
}); | ||
|
||
|
||
// When | ||
|
||
When('the client get service {string}', async function (idService) { | ||
service = await get(`/services/${idService}`); | ||
}); | ||
|
||
|
||
When('the client get all services', async function () { | ||
responseToCheck = await get('/services'); | ||
}); | ||
|
||
|
||
// Then | ||
|
||
Then('the client receives status code of {int}', function (statusCode) { | ||
assert.strictEqual(responseToCheck.status, statusCode); | ||
}); | ||
|
||
Then(/^the client retrieves the list of services$/, function () { | ||
assert.notStrictEqual(responseToCheck.data.length, 0); | ||
}); |
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,30 @@ | ||
Test service | ||
pre-condition: service nel DB | ||
1. get services | ||
2. get service | ||
|
||
Test org | ||
pre-condition: service nel DB | ||
1. create org senza enrollments | ||
2. post /org/serv per creare un enrollment | ||
3. update del servizio | ||
4. update del org | ||
5. get org | ||
6. get serv | ||
7. delete servi | ||
8. delete org | ||
|
||
Test POST spontaneous payment | ||
pre-condition: org e servizio esistenti ed associati | ||
1. invocare la post | ||
|
||
|
||
test flusso aggiunta servizio | ||
1. creazione org con 1 enrollment | ||
2. org aggiunge servizio | ||
|
||
test flusso cancellazione servizio | ||
1. creazione org con 2 enrollment | ||
2. cancella enrollment | ||
|
||
test flusso |