This application API used to expose resources to manage Stock.
- JDK 14
- Spring Boot
- Liquibase H2
- Maven (wrapper to simplify ./mvnw)
- Add lombok plugin in your favorite IDE (IntelliJ)
- github-action
The workflow for development is based on trunk based workflow. Master or main branch is used for current feature development, branches called next are used for next delivery. Next is branch must be stabilized by the development team for delivery, not the process of quality assurance that can slow down development, it's continuous delivery with CI / CD.
More description of the workflow is available on the git workflow
Once everything is set up you can run the project using your favorite IDE or directly with maven. To start your application , simply run:
./mvnw clean install && java -jar controller/target/controller-1.0.jar
The database is generated by liquibase when starting the application.
The database is consulted by this console h2 http://localhost:8080/h2-console
Pipeline is launched automatically following each push in any branch:
- Job CI: Checkout - Build - Test - Sonar - Upload artifact in github
- Job CD: Checkout - Deploy in heroku
Consult workflow pipeline in git repository Consult pipeline result action
To launch your application's tests, run:
./mvnw clean test
The application exposes the API documentation, testable /swagger-ui/ of the application :
http://[host:port]/swagger-ui/ (ex en local : http://localhost:8080/swagger-ui/)
curl -X GET "http://localhost:8080/stock" -H "accept: application/json" -H "version: 3"
Response 200 body :
{
"state": "SOME",
"shoes": [
{
"size": 12,
"color": "BLUE",
"quantity": 10
},
{
"size": 8,
"color": "BLUE",
"quantity": 0
}
]
}
curl -X PATCH "http://localhost:8080/stock" -H "accept: */*" -H "version: 3" -H "Content-Type: application/json" -d
{
"shoes": [
{
"name": "baskets",
"color": "BLUE",
"size": 36,
"quantity": 10
},
{
"name": "classique",
"color": "BLUE",
"size": 12,
"quantity": 1
}
]
}
Response:
- 204 No content
- 400 Stock collection contains duplication shoes or stock capacity greater than 30 shoes
curl -X PATCH "http://localhost:8080/stock/shoes" -H "accept: application/json" -H "version: 3" -H "Content-Type: application/json" -d
{
"name": "basket",
"color":"BLACK",
"quantity":0,
"size":0
}
Response:
- 204 No content
- 400 Stock capacity limited of 30 shoes
Developer can manages Heroku app deployments with Git heroku git Consult the logs heroku:
logs --tail
This is a very simple GitHub action that allows you to deploy to Heroku heroku github-Action