|
| 1 | +# This is a sample HTTP request file for testing purposes |
| 2 | +# You can run the application locally and execute these requests in IntelliJ IDEA to test the API |
| 3 | + |
| 4 | +### Create a new customer with a mail address |
| 5 | +POST http://localhost:8080/customers |
| 6 | +Content-Type: application/json |
| 7 | + |
| 8 | +{ |
| 9 | + "mail": "bob@gmail.com" |
| 10 | +} |
| 11 | + |
| 12 | +> {% |
| 13 | + client.test("Customer created successfully", function () { |
| 14 | + client.assert(response.status === 201, "Response status is not 201"); |
| 15 | + |
| 16 | + const body = typeof response.body === 'string' |
| 17 | + ? JSON.parse(response.body) |
| 18 | + : response.body; |
| 19 | + |
| 20 | + client.assert( |
| 21 | + body.mail && body.mail === "bob@gmail.com", |
| 22 | + "Response body does not contain the expected mail" |
| 23 | + ); |
| 24 | + |
| 25 | + client.assert( |
| 26 | + body.id, |
| 27 | + "Response body does not contain an id" |
| 28 | + ); |
| 29 | + |
| 30 | + client.global.set("customerId", body.id); |
| 31 | + }); |
| 32 | +%} |
| 33 | + |
| 34 | +### Get the created customer by ID from previous request |
| 35 | +GET http://localhost:8080/customers/{{customerId}} |
| 36 | +Accept: application/json |
| 37 | + |
| 38 | +> {% |
| 39 | + client.test("Customer retrieved successfully", function () { |
| 40 | + client.assert(response.status === 200, "Response status is not 200"); |
| 41 | + |
| 42 | + const body = typeof response.body === 'string' |
| 43 | + ? JSON.parse(response.body) |
| 44 | + : response.body; |
| 45 | + |
| 46 | + client.assert( |
| 47 | + body.mail && body.mail === "bob@gmail.com", |
| 48 | + "Response body does not contain the expected mail" |
| 49 | + ); |
| 50 | + |
| 51 | + client.assert( |
| 52 | + body.id && body.id === client.global.get("customerId"), |
| 53 | + "Response body does not contain the expected id" |
| 54 | + ); |
| 55 | + }); |
| 56 | +%} |
0 commit comments