Skip to content

Commit 2814fa3

Browse files
feat: Add sample-requests.http for testing API locally (#46)
Add sample-requests.http. This allows you to run the system locally and test HTTP requests to easily verify that the endpoints work as expected. You can run .http files in IntelliJ IDEA and it will display whether the requests succeeded or failed. This is a faster alternative than opening the Swagger UI to test the endpoints.
1 parent ecf87a7 commit 2814fa3

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

requests/sample-requests.http

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)