This project is a REST API built with Spring Boot for managing bookmarks.
It was developed with a strong focus on software quality, automated testing, and validation of API behavior.
The API allows basic CRUD operations for bookmarks, including:
- Create bookmarks
- Retrieve bookmarks
- Update bookmarks
- Delete bookmarks
Beyond the API itself, the main goal of this project is to demonstrate testing strategies and quality assurance practices applied to backend services.
This project emphasizes real-world testing practices, including:
- Validation of REST endpoints using MockMvc
- Integration testing with Testcontainers (PostgreSQL)
- Unit testing with Mockito
- Input validation and error handling (e.g., HTTP 400 responses)
- Service interaction verification
- High test coverage with meaningful scenarios
- Successful bookmark update
- Invalid payload handling (Bad Request)
- Resource not found scenarios
- Data consistency validation
The test strategy is structured across different levels:
- Use MockMvc to simulate HTTP requests
- Validate status codes and request/response behavior
- Ensure proper validation handling (e.g., invalid payloads)
- Use Mockito for mocking dependencies
- Validate business logic in isolation
- Use Testcontainers with PostgreSQL
- Ensure real database interaction
- Validate persistence and data integrity
Test coverage is measured using JaCoCo, ensuring high confidence in the application behavior.
- Coverage: ~98%
- Includes positive and negative scenarios
- Focus on business logic and validation
Run:
./gradlew clean jacocoTestReport
Then open:
build/reports/jacoco/test/html/index.html
This project was based on and extended from:
https://blog.jetbrains.com/idea/2024/10/how-to-build-a-crud-rest-api-using-spring-boot/
While the initial structure follows the article, the application was significantly refactored and extended with a strong focus on testability and quality.
Key improvements include:
- Refactoring the architecture from a 2-layer structure into a 3-layer design (Controller → Service → Repository)
- Enabling proper isolation of service layer tests
- Improving separation of concerns to support unit and integration testing
- Adding validation scenarios and error handling tests
- Introducing automated testing practices using MockMvc, Mockito, and Testcontainers