A simple REST application with Kotlin
./gradlew clean build
./gradlew clean test
Minimum coverage is 80%, and report in build/jacocoHtml/index.html
./gradlew clean test sonarqube \
-Dsonar.projectKey=<<your-project-key-configured>> \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=<<the-login>>
java -jar build/libs/shopping-cart-<version>.jar
http://localhost:8000/swagger-ui.html
Create a cart associated to a user
curl -X 'POST' \
'http://localhost:8000/cart' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user_id": "123"
}'
{
"user_id": "123",
"products": []
}
Get a cart associated to a user
curl -X 'GET' \
'http://localhost:8000/cart/user/123' \
-H 'accept: application/json'
{
"user_id": "123",
"products": []
}
Add a product to a cart
curl -X 'POST' \
'http://localhost:8000/cart/user/123/products' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"id": 1,
"quantity": 1
}'
{
"user_id": "123",
"products": [
{
"id": 1,
"name": "Shorts",
"price": 55,
"description": "",
"category": "Clothes",
"quantity": 1
}
]
}
Create a product
curl -X 'POST' \
'http://localhost:8000/product' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "Sneakers",
"price": 199.99,
"description": "A blue sneaker",
"category": "Clothes"
}'
{
"id": 4,
"name": "Sneakers",
"price": 199.99,
"description": "A blue sneaker",
"category": "Clothes"
}
Get a product by id
curl -X 'GET' \
'http://localhost:8000/product/4' \
-H 'accept: application/json'
{
"id": 4,
"name": "Sneakers",
"price": 199.99,
"description": "A blue sneaker",
"category": "Clothes"
}