Skip to content

Commit 4a0908e

Browse files
docs: made changes according to comments
Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com>
1 parent cdf9466 commit 4a0908e

File tree

17 files changed

+4314
-1320
lines changed

17 files changed

+4314
-1320
lines changed

spring-petclinic/README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
This is a petclinic app where you can record testcases and mocks by interacting with the UI, and then test them using Keploy.
44
This project has two parts - the frontend and backend, since Keploy is a backend testing platform, we need to start the backend part of the project using Keploy and run the frontend as it is.
55

6+
First, you need to install Keploy. For that you can use the command below:
7+
8+
```
9+
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
10+
```
11+
612
## Setup the frontend
713

814
```
@@ -20,20 +26,15 @@ npm i
2026
```
2127
npm run start
2228
```
23-
## Spin up the database
24-
25-
```
26-
docker run -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 --net keploy-network --name mypostgres postgres:15.2
27-
```
2829

2930
You can start the backend using Keploy in 2 ways:
3031
- [Using Keploy's binary](#binary-guide)
3132
- [Using Keploy's docker image](#docker-guide)
3233

33-
But first, you need to install Keploy. For that you can use the command below:
34+
Lets's move to the backend directory and get started.
3435

3536
```
36-
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
37+
cd samples-java/spring-petclinic/spring-petclinic-rest
3738
```
3839

3940
# Instructions For Starting Using Binary <a name="binary-guide"></a>
@@ -46,16 +47,17 @@ Prerequisites For Binary:
4647
## Setup the backend
4748

4849
```
49-
cd samples-java/spring-petclinic/spring-petclinic-rest
5050
mvn clean install -Dmaven.test.skip=true
5151
```
5252

53-
You also need to update the postgresql properties, go to
53+
## Spin up the database
5454

5555
```
56-
spring-petclinic/spring-petclinic-rest/src/main/resources/application-postgresql.properties
56+
docker run -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 --name mypostgres postgres:15.2
5757
```
5858

59+
You also need to update the postgresql properties, go to
60+
`spring-petclinic/spring-petclinic-rest/src/main/resources/application-postgresql.properties`
5961
and change
6062

6163
```
@@ -67,6 +69,11 @@ to
6769
```
6870
spring.datasource.url=jdbc:postgresql://localhost:5432/petclinic
6971
```
72+
and then build the jar again using
73+
74+
```
75+
mvn clean install -Dmaven.test.skip=true
76+
```
7077

7178
## Recording the testcases with Keploy
7279

@@ -99,4 +106,4 @@ keploy test -c "docker compose up" --containerName javaApp --buildDelay 50s --de
99106
Here `delay` is the time it takes for your application to get started, after which Keploy will start running the testcases. If your application takes longer than 10s to get started, you can change the `delay` accordingly.
100107
`buildDelay` is the time that it takes for the image to get built. This is useful when you are building the docker image from your docker compose file itself.
101108

102-
Hope this helps you out, if you still have any questions, reach out to us on our [Slack](https://join.slack.com/t/keploy/shared_invite/zt-12rfbvc01-o54cOG0X1G6eVJTuI_orSA)
109+
Hope this helps you out, if you still have any questions, reach out to us on our [Slack](https://join.slack.com/t/keploy/shared_invite/zt-12rfbvc01-o54cOG0X1G6eVJTuI_orSA)

spring-petclinic/spring-petclinic-rest/keploy/test-set-0/mocks.yaml

Lines changed: 1054 additions & 1016 deletions
Large diffs are not rendered by default.

spring-petclinic/spring-petclinic-rest/keploy/test-set-0/tests/test-1.yaml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,26 @@ spec:
77
method: GET
88
proto_major: 1
99
proto_minor: 1
10-
url: http://localhost:9967/petclinic/api/pettypes
10+
url: http://localhost:9966/petclinic/api/pettypes
1111
header:
1212
Accept: application/json, text/plain, */*
1313
Accept-Encoding: gzip, deflate, br
1414
Accept-Language: en-US,en;q=0.9
1515
Connection: keep-alive
16-
Host: localhost:9967
17-
Origin: http://localhost:59555
18-
Referer: http://localhost:59555/
19-
Sec-Ch-Ua: '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
16+
Host: localhost:9966
17+
Origin: http://localhost:4200
18+
Referer: http://localhost:4200/
19+
Sec-Ch-Ua: '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"'
2020
Sec-Ch-Ua-Mobile: ?0
2121
Sec-Ch-Ua-Platform: '"macOS"'
2222
Sec-Fetch-Dest: empty
2323
Sec-Fetch-Mode: cors
2424
Sec-Fetch-Site: same-site
25-
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
25+
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
2626
body: ""
2727
body_type: ""
28-
timestamp: 2023-12-09T06:29:56.173072949Z
28+
timestamp: 2024-02-12T16:54:21.054666137+05:30
29+
host: ""
2930
resp:
3031
status_code: 404
3132
header:
@@ -34,7 +35,7 @@ spec:
3435
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
3536
Connection: keep-alive
3637
Content-Length: "0"
37-
Date: Sat, 09 Dec 2023 06:29:56 GMT
38+
Date: Mon, 12 Feb 2024 11:24:21 GMT
3839
Expires: "0"
3940
Keep-Alive: timeout=60
4041
Pragma: no-cache
@@ -47,27 +48,27 @@ spec:
4748
status_message: ""
4849
proto_major: 0
4950
proto_minor: 0
50-
timestamp: 2023-12-09T06:29:58.310490877Z
51+
timestamp: 2024-02-12T16:54:23.272606779+05:30
5152
objects: []
5253
assertions:
5354
noise:
5455
header.Access-Control-Expose-Headers: []
5556
header.Date: []
56-
created: 1702103398
57+
created: 1707737063
5758
curl: |
5859
curl --request GET \
59-
--url http://localhost:9967/petclinic/api/pettypes \
60-
--header 'Sec-Ch-Ua-Mobile: ?0' \
61-
--header 'Accept: application/json, text/plain, */*' \
62-
--header 'Sec-Fetch-Site: same-site' \
60+
--url http://localhost:9966/petclinic/api/pettypes \
61+
--header 'Referer: http://localhost:4200/' \
6362
--header 'Accept-Language: en-US,en;q=0.9' \
6463
--header 'Sec-Ch-Ua-Platform: "macOS"' \
6564
--header 'Accept-Encoding: gzip, deflate, br' \
66-
--header 'Origin: http://localhost:59555' \
65+
--header 'Sec-Ch-Ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
66+
--header 'Host: localhost:9966' \
67+
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
6768
--header 'Connection: keep-alive' \
68-
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
69-
--header 'Host: localhost:9967' \
70-
--header 'Sec-Fetch-Dest: empty' \
71-
--header 'Sec-Ch-Ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
72-
--header 'Referer: http://localhost:59555/' \
69+
--header 'Accept: application/json, text/plain, */*' \
7370
--header 'Sec-Fetch-Mode: cors' \
71+
--header 'Sec-Fetch-Dest: empty' \
72+
--header 'Sec-Ch-Ua-Mobile: ?0' \
73+
--header 'Origin: http://localhost:4200' \
74+
--header 'Sec-Fetch-Site: same-site' \

spring-petclinic/spring-petclinic-rest/keploy/test-set-0/tests/test-10.yaml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@ name: test-10
44
spec:
55
metadata: {}
66
req:
7-
method: PUT
7+
method: POST
88
proto_major: 1
99
proto_minor: 1
10-
url: http://localhost:9967/petclinic/api/pettypes/1
10+
url: http://localhost:9966/petclinic/api/vets
1111
header:
1212
Accept: application/json, text/plain, */*
1313
Accept-Encoding: gzip, deflate, br
1414
Accept-Language: en-US,en;q=0.9
1515
Connection: keep-alive
16-
Content-Length: "22"
16+
Content-Length: "70"
1717
Content-Type: application/json
18-
Host: localhost:9967
19-
Origin: http://localhost:59555
20-
Referer: http://localhost:59555/
21-
Sec-Ch-Ua: '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
18+
Host: localhost:9966
19+
Origin: http://localhost:4200
20+
Referer: http://localhost:4200/
21+
Sec-Ch-Ua: '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"'
2222
Sec-Ch-Ua-Mobile: ?0
2323
Sec-Ch-Ua-Platform: '"macOS"'
2424
Sec-Fetch-Dest: empty
2525
Sec-Fetch-Mode: cors
2626
Sec-Fetch-Site: same-site
27-
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
28-
body: '{"id":1,"name":"Cats"}'
27+
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
28+
body: '{"id":null,"firstName":"Alice ","lastName":"Hopkins","specialties":[]}'
2929
body_type: ""
30-
timestamp: 2023-12-09T06:32:02.104894269Z
30+
timestamp: 2024-02-12T16:55:00.533630021+05:30
31+
host: ""
3132
resp:
32-
status_code: 204
33+
status_code: 400
3334
header:
3435
Access-Control-Allow-Origin: '*'
3536
Access-Control-Expose-Headers: errors, content-type
3637
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
37-
Connection: keep-alive
38-
Content-Type: application/json
39-
Date: Sat, 09 Dec 2023 06:32:02 GMT
38+
Content-Length: "0"
39+
Date: Mon, 12 Feb 2024 11:25:00 GMT
40+
Errors: '[{"objectName":"vetDto","fieldName":"firstName","fieldValue":"Alice ","errorMessage":"must match \"^[a-zA-Z]*$\""}]'
4041
Expires: "0"
41-
Keep-Alive: timeout=60
4242
Pragma: no-cache
4343
Vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
4444
X-Content-Type-Options: nosniff
@@ -49,29 +49,29 @@ spec:
4949
status_message: ""
5050
proto_major: 0
5151
proto_minor: 0
52-
timestamp: 2023-12-09T06:32:02.135805046Z
52+
timestamp: 2024-02-12T16:55:03.593634538+05:30
5353
objects: []
5454
assertions:
5555
noise:
5656
header.Access-Control-Expose-Headers: []
5757
header.Date: []
58-
created: 1702103522
58+
created: 1707737103
5959
curl: |-
60-
curl --request PUT \
61-
--url http://localhost:9967/petclinic/api/pettypes/1 \
62-
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
63-
--header 'Sec-Ch-Ua-Mobile: ?0' \
60+
curl --request POST \
61+
--url http://localhost:9966/petclinic/api/vets \
62+
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
6463
--header 'Content-Type: application/json' \
65-
--header 'Host: localhost:9967' \
66-
--header 'Origin: http://localhost:59555' \
67-
--header 'Accept-Language: en-US,en;q=0.9' \
68-
--header 'Connection: keep-alive' \
69-
--header 'Referer: http://localhost:59555/' \
7064
--header 'Sec-Fetch-Mode: cors' \
71-
--header 'Sec-Fetch-Site: same-site' \
72-
--header 'Sec-Ch-Ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
7365
--header 'Sec-Fetch-Dest: empty' \
7466
--header 'Accept-Encoding: gzip, deflate, br' \
67+
--header 'Host: localhost:9966' \
68+
--header 'Referer: http://localhost:4200/' \
7569
--header 'Accept: application/json, text/plain, */*' \
7670
--header 'Sec-Ch-Ua-Platform: "macOS"' \
77-
--data '{"id":1,"name":"Cats"}'
71+
--header 'Sec-Ch-Ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
72+
--header 'Sec-Ch-Ua-Mobile: ?0' \
73+
--header 'Origin: http://localhost:4200' \
74+
--header 'Accept-Language: en-US,en;q=0.9' \
75+
--header 'Connection: keep-alive' \
76+
--header 'Sec-Fetch-Site: same-site' \
77+
--data '{"id":null,"firstName":"Alice ","lastName":"Hopkins","specialties":[]}'

spring-petclinic/spring-petclinic-rest/keploy/test-set-0/tests/test-11.yaml

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,77 @@ name: test-11
44
spec:
55
metadata: {}
66
req:
7-
method: GET
7+
method: POST
88
proto_major: 1
99
proto_minor: 1
10-
url: http://localhost:9967/petclinic/api/pettypes
10+
url: http://localhost:9966/petclinic/api/owners
1111
header:
1212
Accept: application/json, text/plain, */*
1313
Accept-Encoding: gzip, deflate, br
1414
Accept-Language: en-US,en;q=0.9
1515
Connection: keep-alive
16-
Host: localhost:9967
17-
Origin: http://localhost:59555
18-
Referer: http://localhost:59555/
19-
Sec-Ch-Ua: '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
16+
Content-Length: "155"
17+
Content-Type: application/json
18+
Host: localhost:9966
19+
Origin: http://localhost:4200
20+
Referer: http://localhost:4200/
21+
Sec-Ch-Ua: '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"'
2022
Sec-Ch-Ua-Mobile: ?0
2123
Sec-Ch-Ua-Platform: '"macOS"'
2224
Sec-Fetch-Dest: empty
2325
Sec-Fetch-Mode: cors
2426
Sec-Fetch-Site: same-site
25-
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
26-
body: ""
27+
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
28+
body: '{"id":null,"firstName":"Joe","lastName":"Hopkins","address":"24th Main Street, Something Street","city":"Los Angeles, California","telephone":"9090812030"}'
2729
body_type: ""
28-
timestamp: 2023-12-09T06:32:02.135472827Z
30+
timestamp: 2024-02-12T16:55:50.028129439+05:30
31+
host: ""
2932
resp:
30-
status_code: 200
33+
status_code: 201
3134
header:
3235
Access-Control-Allow-Origin: '*'
3336
Access-Control-Expose-Headers: errors, content-type
3437
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
3538
Connection: keep-alive
3639
Content-Type: application/json
37-
Date: Sat, 09 Dec 2023 06:32:02 GMT
40+
Date: Mon, 12 Feb 2024 11:25:50 GMT
3841
Expires: "0"
3942
Keep-Alive: timeout=60
43+
Location: /api/owners/2
4044
Pragma: no-cache
4145
Vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
4246
X-Content-Type-Options: nosniff
4347
X-Frame-Options: DENY
4448
X-Xss-Protection: "0"
45-
body: '[{"name":"Cats","id":1}]'
49+
body: '{"firstName":"Joe","lastName":"Hopkins","address":"24th Main Street, Something Street","city":"Los Angeles, California","telephone":"9090812030","id":2,"pets":[]}'
4650
body_type: ""
4751
status_message: ""
4852
proto_major: 0
4953
proto_minor: 0
50-
timestamp: 2023-12-09T06:32:05.472305151Z
54+
timestamp: 2024-02-12T16:55:50.095389844+05:30
5155
objects: []
5256
assertions:
5357
noise:
58+
body.telephone: []
5459
header.Access-Control-Expose-Headers: []
5560
header.Date: []
56-
created: 1702103525
57-
curl: |
58-
curl --request GET \
59-
--url http://localhost:9967/petclinic/api/pettypes \
60-
--header 'Sec-Ch-Ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
61-
--header 'Referer: http://localhost:59555/' \
62-
--header 'Sec-Fetch-Dest: empty' \
63-
--header 'Sec-Fetch-Mode: cors' \
64-
--header 'Sec-Ch-Ua-Platform: "macOS"' \
61+
created: 1707737150
62+
curl: |-
63+
curl --request POST \
64+
--url http://localhost:9966/petclinic/api/owners \
65+
--header 'Origin: http://localhost:4200' \
6566
--header 'Accept-Encoding: gzip, deflate, br' \
66-
--header 'Sec-Fetch-Site: same-site' \
67-
--header 'Sec-Ch-Ua-Mobile: ?0' \
68-
--header 'Origin: http://localhost:59555' \
67+
--header 'Sec-Fetch-Mode: cors' \
68+
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
6969
--header 'Connection: keep-alive' \
70-
--header 'Accept-Language: en-US,en;q=0.9' \
71-
--header 'Host: localhost:9967' \
70+
--header 'Host: localhost:9966' \
7271
--header 'Accept: application/json, text/plain, */*' \
73-
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
72+
--header 'Referer: http://localhost:4200/' \
73+
--header 'Sec-Ch-Ua-Mobile: ?0' \
74+
--header 'Sec-Fetch-Site: same-site' \
75+
--header 'Sec-Ch-Ua-Platform: "macOS"' \
76+
--header 'Sec-Ch-Ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
77+
--header 'Sec-Fetch-Dest: empty' \
78+
--header 'Accept-Language: en-US,en;q=0.9' \
79+
--header 'Content-Type: application/json' \
80+
--data '{"id":null,"firstName":"Joe","lastName":"Hopkins","address":"24th Main Street, Something Street","city":"Los Angeles, California","telephone":"9090812030"}'

0 commit comments

Comments
 (0)