Skip to content

Latest commit

 

History

History

user-manager

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Example User-Manager App

A sample User-Manager app to test Keploy integration capabilities using SpringBoot and MongoDB.

Note :- Issue Creation is disabled on this Repository, please visit here to submit Issue.

Pre-requisites

Quick Keploy Installation

Based on your OS and preference(Docker/Native), you setup Keploy using One-click installation method:-

curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh

Setup Employee-Manager App

Clone the repository and install the dependencies

git clone https://github.com/keploy/samples-java && cd user-manager

mvn clean install -Dmaven.test.skip=true 

Capture the testcases

Once we have our jar file ready,this command will start the recording of API calls using ebpf:-

sudo -E env PATH=$PATH keploy record -c "java -jar target/user-manager-1.0-SNAPSHOT.jar"

Testcases

Now let's run a few tests to capture some more scenarios:

Generate testcases

To generate testcases we just need to make some API calls. You can use Postman, Hoppscotch, or simply curl

  1. Make a user entry
curl --location --request POST 'http://localhost:8081/api/user' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id": 1,
    "name": "Dan",
    "age": "23",
    "birthday": "2000-1-1"
}'

this will return the response or an entry.

{"id":1,"name":"Dan","age":23,"birthday":"2000-1-1"}
  1. Fetch recorded info about users
curl --location --request GET 'http://localhost:8081/api/user/1'

or by querying through the browser http://localhost:8081/api/user/1

  1. Update user record
curl -X PUT -H "Content-Type: application/json" \
-d '{
    "id": 1,
    "name": "Update DAN",
    "age": "22",
    "birthday": "2001-2-2"
}' \
'http://localhost:8081/api/user/1'

this will return the response or an entry.

{"id":1,"name":"Update DAN","age":22,"birthday":"2001-2-2"}
  1. Delete user record
curl -X DELETE 'http://localhost:8081/api/user/1'

Now both these API calls were captured as editable testcases and written to keploy/test folder. The keploy directory would also have mock.yml file.

Now, let's see the magic! 🪄💫

Run the test cases

Now, let's run the keploy in test mode: -

sudo -E env PATH=$PATH keploy test -c "java -jar target/user-manager-1.0-SNAPSHOT.jar" --delay 10

This will run the testcases and generate the report in keploy/testReports folder.