-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #752 from achtzig20/feat/days-of-supply-bruno
feat: bruno integration tests for days of supply
- Loading branch information
Showing
17 changed files
with
806 additions
and
6 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
117 changes: 117 additions & 0 deletions
117
.../Test_01-MAD/01_02-Operational Data/Customer/Supply/Create new Delivery Semiconductor.bru
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,117 @@ | ||
meta { | ||
name: Create new Delivery Semiconductor | ||
type: http | ||
seq: 2 | ||
} | ||
|
||
post { | ||
url: {{CUSTOMER_PURIS_BACKEND}}/catena/delivery | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
X-Api-Key: {{CUSTOMER_PURIS_BACKEND_API_KEY}} | ||
} | ||
|
||
body:json { | ||
{ | ||
"partnerBpnl": "{{SUPPLIER_BPNL}}", | ||
"ownMaterialNumber": "{{MATERIAL_NUMBER_CUSTOMER}}", | ||
"quantity": 1500, | ||
"measurementUnit": "unit:piece", | ||
"trackingNumber": "TN2", | ||
"incoterm": "FAS", | ||
"supplierOrderNumber": null, | ||
"customerOrderNumber": "C-Nbr-1", | ||
"customerOrderPositionNumber": "C-Position-01", | ||
"destinationBpns": "{{CUSTOMER_BPNS}}", | ||
"destinationBpna": "{{CUSTOMER_BPNA}}", | ||
"originBpns": "{{SUPPLIER_BPNS}}", | ||
"originBpna": "{{SUPPLIER_BPNA}}", | ||
"dateOfDeparture": "{{DEPARTURE_TIME_CALCULATED}}", | ||
"dateOfArrival": "{{ARRIVAL_TIME_CALCULATED}}", | ||
"departureType": "estimated-departure", | ||
"arrivalType": "estimated-arrival" | ||
} | ||
} | ||
|
||
script:pre-request { | ||
// Create the formattedDate | ||
const today = new Date(); | ||
today.setDate(today.getDate() + 7); | ||
const departureDateFormatted = today.toISOString(); | ||
|
||
// set arrival date 2 days after departure | ||
today.setDate(today.getDate() + 1); | ||
const arrivalDateFormatted = today.toISOString(); | ||
|
||
// Set the formattedDate in the environment variable | ||
bru.setVar('DEPARTURE_TIME_CALCULATED', departureDateFormatted); | ||
bru.setVar('ARRIVAL_TIME_CALCULATED', arrivalDateFormatted); | ||
|
||
} | ||
|
||
tests { | ||
test("response is ok", function() { | ||
expect(res.getStatus()).to.equal(201); | ||
}); | ||
|
||
test("Verify delivery composition (material number with BPNS, BPNA and Partner BPNL)", function () { | ||
const responseJson = res.getBody(); | ||
|
||
expect(responseJson).to.have.property("uuid"); | ||
expect(responseJson.uuid).to.not.be.undefined; | ||
|
||
expect(responseJson).to.have.property("ownMaterialNumber"); | ||
expect(responseJson.ownMaterialNumber).to.equal(bru.getEnvVar("MATERIAL_NUMBER_CUSTOMER")); | ||
|
||
expect(responseJson).to.have.property("partnerBpnl"); | ||
expect(responseJson.partnerBpnl).to.equal(bru.getEnvVar("SUPPLIER_BPNL")); | ||
|
||
expect(responseJson).to.have.property("quantity"); | ||
expect(responseJson.quantity).to.equal(1500); | ||
|
||
expect(responseJson).to.have.property("measurementUnit"); | ||
expect(responseJson.measurementUnit).to.equal("unit:piece"); | ||
|
||
expect(responseJson).to.have.property("trackingNumber"); | ||
expect(responseJson.trackingNumber).to.equal("TN2"); | ||
|
||
expect(responseJson).to.have.property("incoterm"); | ||
expect(responseJson.incoterm).to.equal("FAS"); | ||
|
||
expect(responseJson).to.have.property("supplierOrderNumber"); | ||
expect(responseJson.supplierOrderNumber).to.equal(null); | ||
|
||
expect(responseJson).to.have.property("customerOrderNumber"); | ||
expect(responseJson.customerOrderNumber).to.equal("C-Nbr-1"); | ||
|
||
expect(responseJson).to.have.property("customerOrderPositionNumber"); | ||
expect(responseJson.customerOrderPositionNumber).to.equal("C-Position-01"); | ||
|
||
expect(responseJson).to.have.property("destinationBpns"); | ||
expect(responseJson.destinationBpns).to.equal(bru.getEnvVar("CUSTOMER_BPNS")); | ||
|
||
expect(responseJson).to.have.property("destinationBpna"); | ||
expect(responseJson.destinationBpna).to.equal(bru.getEnvVar("CUSTOMER_BPNA")); | ||
|
||
expect(responseJson).to.have.property("originBpns"); | ||
expect(responseJson.originBpns).to.equal(bru.getEnvVar("SUPPLIER_BPNS")); | ||
|
||
expect(responseJson).to.have.property("originBpna"); | ||
expect(responseJson.originBpna).to.equal(bru.getEnvVar("SUPPLIER_BPNA")); | ||
|
||
expect(responseJson).to.have.property("dateOfDeparture"); | ||
expect(new Date(responseJson.dateOfDeparture).toISOString()).to.equal(bru.getVar("DEPARTURE_TIME_CALCULATED")); | ||
|
||
expect(responseJson).to.have.property("dateOfArrival"); | ||
expect(new Date(responseJson.dateOfArrival).toISOString()).to.equal(bru.getVar("ARRIVAL_TIME_CALCULATED")); | ||
|
||
expect(responseJson).to.have.property("departureType"); | ||
expect(responseJson.departureType).to.equal("estimated-departure"); | ||
|
||
expect(responseJson).to.have.property("arrivalType"); | ||
expect(responseJson.arrivalType).to.equal("estimated-arrival"); | ||
}); | ||
} |
64 changes: 64 additions & 0 deletions
64
...1-MAD/01_02-Operational Data/Customer/Supply/Create new Demand Semiconductor Material.bru
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,64 @@ | ||
meta { | ||
name: Create new Demand Semiconductor Material | ||
type: http | ||
seq: 4 | ||
} | ||
|
||
post { | ||
url: {{CUSTOMER_PURIS_BACKEND}}/catena/demand | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
X-Api-Key: {{CUSTOMER_PURIS_BACKEND_API_KEY}} | ||
} | ||
|
||
body:json { | ||
{ | ||
"partnerBpnl": "{{SUPPLIER_BPNL}}", | ||
"ownMaterialNumber": "{{MATERIAL_NUMBER_CUSTOMER}}", | ||
"quantity": 810.00, | ||
"measurementUnit": "unit:piece", | ||
"day": "{{DATE_TIME_CALCULATED}}", | ||
"demandLocationBpns": "{{CUSTOMER_BPNS}}", | ||
"supplierLocationBpns": "{{SUPPLIER_BPNS}}", | ||
"demandCategoryCode": "A1S1" | ||
} | ||
} | ||
|
||
script:pre-request { | ||
// Create the formattedDate | ||
const today = new Date(); | ||
today.setDate(today.getDate() + 11); | ||
const dateFormatted = today.toISOString().slice(0, 16); | ||
|
||
// Set the formattedDate in the environment variable | ||
bru.setVar('DATE_TIME_CALCULATED', dateFormatted); | ||
|
||
} | ||
|
||
tests { | ||
test("response is ok", function() { | ||
expect(res.getStatus()).to.equal(201); | ||
}); | ||
|
||
test("Verify demand composition (material number with BPNS, BPNA and Partner BPNL)", function () { | ||
var responseJson = res.getBody(); | ||
|
||
expect(responseJson).to.have.property("uuid"); | ||
expect(responseJson.uuid).to.not.undefined; | ||
|
||
expect(responseJson).to.have.property("ownMaterialNumber"); | ||
expect(responseJson.ownMaterialNumber).to.equal(bru.getEnvVar("MATERIAL_NUMBER_CUSTOMER")); | ||
|
||
expect(responseJson).to.have.property("partnerBpnl"); | ||
expect(responseJson.partnerBpnl).to.equal(bru.getEnvVar("SUPPLIER_BPNL")); | ||
|
||
expect(responseJson).to.have.property("demandLocationBpns"); | ||
expect(responseJson.demandLocationBpns).to.equal(bru.getEnvVar("CUSTOMER_BPNS")); | ||
|
||
expect(responseJson).to.have.property("supplierLocationBpns"); | ||
expect(responseJson.supplierLocationBpns).to.equal(bru.getEnvVar("SUPPLIER_BPNS")); | ||
}); | ||
} |
66 changes: 66 additions & 0 deletions
66
...1-MAD/01_02-Operational Data/Customer/Supply/Get Customer Days of Supply after Demand.bru
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,66 @@ | ||
meta { | ||
name: Get Customer Days of Supply after Demand | ||
type: http | ||
seq: 5 | ||
} | ||
|
||
get { | ||
url: {{CUSTOMER_PURIS_BACKEND}}/catena/days-of-supply/customer?bpnl={{SUPPLIER_BPNL}}&siteBpns={{CUSTOMER_BPNS}}&numberOfDays=28&materialNumber={{MATERIAL_NUMBER_CUSTOMER_BASE64}} | ||
body: none | ||
auth: none | ||
} | ||
|
||
params:query { | ||
bpnl: {{SUPPLIER_BPNL}} | ||
siteBpns: {{CUSTOMER_BPNS}} | ||
numberOfDays: 28 | ||
materialNumber: {{MATERIAL_NUMBER_CUSTOMER_BASE64}} | ||
} | ||
|
||
headers { | ||
X-API-KEY: {{CUSTOMER_PURIS_BACKEND_API_KEY}} | ||
} | ||
|
||
tests { | ||
test("response is ok", function() { | ||
expect(res.getStatus()).to.equal(200); | ||
}); | ||
|
||
const responseJson = res.getBody(); | ||
|
||
test("Verify response contains 27 daysOfSupply items", function () { | ||
expect(responseJson).to.be.an("array").with.lengthOf(27); | ||
}); | ||
|
||
const expectedSupplies = [ | ||
0.10, | ||
0, 0, 0, 0, 0, 0, 0, | ||
2.79, | ||
1.79, | ||
0.79, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
]; | ||
|
||
test("Verify days of supply values in array", function () { | ||
responseJson.forEach((item, i) => { | ||
expect(item).to.have.property("daysOfSupply"); | ||
expect(item.daysOfSupply.toFixed(2)).to.equal(expectedSupplies[i].toFixed(2)); | ||
}) | ||
}); | ||
|
||
test("Verify date values in array", function () { | ||
const today = new Date(); | ||
today.setHours(0, 0, 0, 0); | ||
responseJson.forEach((item, i) => { | ||
const date = new Date(today); | ||
date.setDate(date.getDate() + i); | ||
const supplyDate = new Date(item.date); | ||
const offset = supplyDate.getTimezoneOffset() / 60; | ||
supplyDate.setHours(supplyDate.getHours() - offset); | ||
supplyDate.setHours(0,0,0,0); | ||
expect(item).to.have.property("date"); | ||
expect(supplyDate.toISOString()).to.equal(date.toISOString()); | ||
}) | ||
}); | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...n-test/Test_01-MAD/01_02-Operational Data/Customer/Supply/Get Customer Days of Supply.bru
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,64 @@ | ||
meta { | ||
name: Get Customer Days of Supply | ||
type: http | ||
seq: 3 | ||
} | ||
|
||
get { | ||
url: {{CUSTOMER_PURIS_BACKEND}}/catena/days-of-supply/customer?bpnl={{SUPPLIER_BPNL}}&siteBpns={{CUSTOMER_BPNS}}&numberOfDays=28&materialNumber={{MATERIAL_NUMBER_CUSTOMER_BASE64}} | ||
body: none | ||
auth: none | ||
} | ||
|
||
params:query { | ||
bpnl: {{SUPPLIER_BPNL}} | ||
siteBpns: {{CUSTOMER_BPNS}} | ||
numberOfDays: 28 | ||
materialNumber: {{MATERIAL_NUMBER_CUSTOMER_BASE64}} | ||
} | ||
|
||
headers { | ||
X-API-KEY: {{CUSTOMER_PURIS_BACKEND_API_KEY}} | ||
} | ||
|
||
tests { | ||
test("response is ok", function() { | ||
expect(res.getStatus()).to.equal(200); | ||
}); | ||
|
||
const responseJson = res.getBody(); | ||
|
||
test("Verify response contains 27 daysOfSupply items", function () { | ||
expect(responseJson).to.be.an("array").with.lengthOf(27); | ||
}); | ||
|
||
const expectedSupplies = [ | ||
0.1, | ||
0, | ||
0, 0, 0, 0, 0, 0, | ||
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 | ||
]; | ||
|
||
test("Verify days of supply values in array", function () { | ||
responseJson.forEach((item, i) => { | ||
expect(item).to.have.property("daysOfSupply"); | ||
expect(item.daysOfSupply.toFixed(2)).to.equal(expectedSupplies[i].toFixed(2)); | ||
}) | ||
}); | ||
|
||
test("Verify date values in array", function () { | ||
const today = new Date(); | ||
today.setHours(0, 0, 0, 0); | ||
responseJson.forEach((item, i) => { | ||
const date = new Date(today); | ||
date.setDate(date.getDate() + i); | ||
const supplyDate = new Date(item.date); | ||
const offset = supplyDate.getTimezoneOffset() / 60; | ||
supplyDate.setHours(supplyDate.getHours() - offset); | ||
supplyDate.setHours(0,0,0,0); | ||
expect(item).to.have.property("date"); | ||
expect(supplyDate.toISOString()).to.equal(date.toISOString()); | ||
}) | ||
}); | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...est_01-MAD/01_02-Operational Data/Customer/Supply/Get Initial Customer Days of Supply.bru
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,63 @@ | ||
meta { | ||
name: Get Initial Customer Days of Supply | ||
type: http | ||
seq: 1 | ||
} | ||
|
||
get { | ||
url: {{CUSTOMER_PURIS_BACKEND}}/catena/days-of-supply/customer?bpnl={{SUPPLIER_BPNL}}&siteBpns={{CUSTOMER_BPNS}}&numberOfDays=28&materialNumber={{MATERIAL_NUMBER_CUSTOMER_BASE64}} | ||
body: none | ||
auth: none | ||
} | ||
|
||
params:query { | ||
bpnl: {{SUPPLIER_BPNL}} | ||
siteBpns: {{CUSTOMER_BPNS}} | ||
numberOfDays: 28 | ||
materialNumber: {{MATERIAL_NUMBER_CUSTOMER_BASE64}} | ||
} | ||
|
||
headers { | ||
X-API-KEY: {{CUSTOMER_PURIS_BACKEND_API_KEY}} | ||
} | ||
|
||
tests { | ||
test("response is ok", function() { | ||
expect(res.getStatus()).to.equal(200); | ||
}); | ||
|
||
const responseJson = res.getBody(); | ||
|
||
test("Verify response contains 27 daysOfSupply items", function () { | ||
expect(responseJson).to.be.an("array").with.lengthOf(27); | ||
}); | ||
|
||
const expectedSupplies = [ | ||
0.1, | ||
0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
]; | ||
|
||
test("Verify days of supply values in array", function () { | ||
responseJson.forEach((item, i) => { | ||
expect(item).to.have.property("daysOfSupply"); | ||
expect(item.daysOfSupply.toFixed(2)).to.equal(expectedSupplies[i].toFixed(2)); | ||
}) | ||
}); | ||
|
||
test("Verify date values in array", function () { | ||
const today = new Date(); | ||
today.setHours(0, 0, 0, 0); | ||
responseJson.forEach((item, i) => { | ||
const date = new Date(today); | ||
date.setDate(date.getDate() + i); | ||
const supplyDate = new Date(item.date); | ||
const offset = supplyDate.getTimezoneOffset() / 60; | ||
supplyDate.setHours(supplyDate.getHours() - offset); | ||
supplyDate.setHours(0,0,0,0); | ||
expect(item).to.have.property("date"); | ||
expect(supplyDate.toISOString()).to.equal(date.toISOString()); | ||
}) | ||
}); | ||
|
||
} |
Oops, something went wrong.