Primary validation command
mvn clean verify
This command regenerates OpenAPI and MapStruct sources, compiles the application, runs unit and web-layer tests, executes PostgreSQL integration tests through Maven Failsafe, packages the service, and generates JaCoCo reports.
Docker must be running before verification because the integration suite starts a real PostgreSQL container. Skipped-test commands are not the standard validation path.
Test layers
Service tests
UserServiceV1Test and UserServiceV2Test exercise business rules and collaborations in isolation.
Controller tests
UsersV1ControllerTest and UsersV2ControllerTest use MockMvc to verify HTTP behavior, payloads, validation, and error translation.
Repository integration
UserRepositoryIT verifies field round trips and database constraints against containerized PostgreSQL.
Application integration
UserServiceIT loads the Spring context, applies Flyway migrations, and verifies complete persistence-backed flows.
Covered behavior
- Create and retrieve users through v1 and v2 contracts.
- Patch v2 profile and status fields.
- Soft-delete a v1 user by transitioning it to
INACTIVE. - Reject duplicate email addresses with a conflict response.
- Preserve the conflict response when concurrent inserts reach the database uniqueness constraint.
- Return a not-found response for unknown user identifiers.
- Reject invalid request bodies and malformed inputs where applicable.
- Hash passwords before persistence rather than storing the submitted value.
- Apply the real Flyway schema before JPA validation.
Testcontainers behavior
PostgresIntegrationTest provides the shared PostgreSQL container configuration. Dynamic Spring properties point the application context at the container's mapped JDBC port, so tests do not depend on a locally installed database or the Compose db service.
Testcontainers needs access to the Docker daemon and may pull the PostgreSQL image on the first run. Subsequent executions generally reuse the local image cache.
Conventions for new tests
- Assert observable behavior, status codes, response bodies, persisted state, and business outcomes.
- Keep controller tests focused on HTTP boundaries and service tests focused on business behavior.
- Use PostgreSQL Testcontainers when database semantics or migrations matter.
- Do not add empty context-load tests, assertion-free tests, or duplicate permutations only to raise coverage.
- Name integration tests with the
*ITsuffix so Maven Failsafe executes them duringverify.
Reports after verification
- Unit test reports:
target/surefire-reports - Integration test reports:
target/failsafe-reports - JaCoCo HTML report:
target/site/jacoco/index.html - JaCoCo XML report:
target/site/jacoco/jacoco.xml