This should be purely a REST endpoints backend application without UI, but feel free to attach Swagger UI for convenience.
- Build tool: Maven
- DB: Postgres
- Source Control: GitHub (public)
- Application name: articles-backend-app
Application must be implemented using Spring Data (JPA/Hibernate) layer for communication with DB.
SQL queries should not be used, JPA Repositories and Entities should be used instead.
Application should have no authentication.
Application will allow to create, update and delete Articles.
Application will have authors
entity with the following properties:
- First Name
- Last Name
Article will have the following properties:
Editable properties (updatable via endpoints):
- Title , text limited to 100 characters
- Summary , text limited to 255 characters
- Text , text with no specific limit
- Author: relation with the authors table . ONLY updatable at creation. Should not be updatable after Article has been created
Non-Editable properties, updated automatically by Application:
- Date Created
- Date Updated
Application should expose REST endpoints that allow the following operations:
- Create new Article
- Update existing Article
- Only one property at the time should be updatable.
- Delete existing Article
- Retrieve all articles in the system sorted by title
The Article JSON Payload returned by endpoint(s) must contain all properties of Article listed above.
Business Logic layer of the Application must enforce the following rules:
- Non-editable properties cannot be updated/set via the create or update endpoints
- Article cannot be created or update with empty Title or Text or Author ID
- Article cannot be created with specified author id that does not exist in the authors table
Any business logic constraint violation or any runtime error should return an HTTP 500 error with short description.
(Guys confirmed that 400 errors could be used instead when needed as more appropriate)
The implementation must contain adequate unit tests to cover business requirements and edge cases such as missing arguments etc.
Application must build and produce an executable jar containing all dependencies.
The authors table should not be updatable via endpoints. Feel free to populate it with an arbitrary data via SQL.
- Operation for getting existing Article
- Add pagination support for
Retrieve all articles
operation - Operations for getting authors
- Maven 3
- JDK 21
mvn clean install
Result jar
placed into target folder
docker build ./ -t articles-backend-app
Result Docker image has name articles-backend-app
as mentioned in command
mvn spring-boot:run -Dspring-boot.run.arguments="\
--spring.datasource.url=jdbc:h2:mem:testdb \
--spring.datasource.username=sa \
--spring.datasource.password=password \
--spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect"
Or next way, using dev
spring profile:
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=dev
java -jar target/articles-backend-app-0.0.1-SNAPSHOT.jar \
--spring.datasource.url=jdbc:h2:mem:testdb \
--spring.datasource.username=sa \
--spring.datasource.password=password \
--spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
Or next way, using dev
spring profile:
java -jar target/articles-backend-app-0.0.1-SNAPSHOT.jar \
--spring.profiles.active=dev
docker-compose up
http://localhost:8099/api/v1/articles
http://localhost:8099/swagger-ui.html
less ./logs/spring-boot-logger.log
docker exec -it articles-backend-app sh
less /logs/spring-boot-logger.log
curl -i -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d '{ "title": "Some tittle", "text": "Some text", "author": { "id": 1 } }' http://localhost:8099/api/v1/articles
curl -i http://localhost:8099/api/v1/articles/1
curl -i -X PATCH -H "Accept: application/json" -H "Content-Type: application/json" -d '{ "title": "Another tittle" }' http://localhost:8099/api/v1/articles/2
curl -i http://localhost:8099/api/v1/articles
curl -i 'http://localhost:8099/api/v1/articles?size=2&page=4&sort=author.firstName,DESC'
curl -i -X DELETE http://localhost:8099/api/v1/articles/1
curl -i http://localhost:8099/api/v1/authors/4
curl -i http://localhost:8099/api/v1/authors
cd func-test
./gradlew clean build
Check Spock report at func-test/build/spock-reports/index.html
Gradle-based:
cd load-test
./gradlew clean build
java -Dlogback.configurationFile=logback-gatling.xml -jar ./build/libs/articles-backend-app-load-test-fat.jar -s=load.WebAppLoadSimulation -rf=./build/reports/gatling
Or Maven-based:
cd load-test
mvn clean install
mvn gatling:test -Dlogback.configurationFile=logback-gatling.xml
Based on https://gatling.io/docs/3.0/extensions/maven_plugin
Just open page http://localhost:8099 and click Connect
.
Check heartbeat logs in browser developer console.
Check ELK README with details