-
Notifications
You must be signed in to change notification settings - Fork 2
Backend Testing
The backend test suite ensures reliability across reactive endpoints, business service logic, data persistence, and external service communication using JUnit, Mockito, Project Reactor StepVerifier, and Testcontainers.
- Unit Tests: Fast, isolated tests mocking dependencies via Mockito.
-
Reactive Stream Tests: Verify non-blocking publishers (
MonoandFlux) usingreactor.test.StepVerifier. - Integration Tests: Spin up ephemeral PostgreSQL and Oracle containers via Testcontainers to validate R2DBC repositories and Flyway migrations against actual database engines.
# Run unit tests and Testcontainers integration tests
cd backend
mvn clean verify -P all-tests
cd legacy
mvn clean verify -P all-tests
cd processor
mvn clean verify -P all-testsNote
Running mvn clean verify -P all-tests executes both unit tests and Testcontainers integration tests. To run only fast unit tests without starting Docker containers, execute mvn clean test.
Because Spring WebFlux operates asynchronously, always assert publishers using StepVerifier:
@Test
void shouldRetrieveClientDetails() {
Mono<ClientDetailsDto> clientMono = clientService.getClientByNumber("00012345");
StepVerifier.create(clientMono)
.assertNext(client -> {
assertNotNull(client);
assertEquals("00012345", client.clientNumber());
assertEquals("ACTIVE", client.clientStatusCode());
})
.verifyComplete();
}Integration tests bootstrap true PostgreSQL instances using @Testcontainers:
@SpringBootTest
@Testcontainers
class SubmissionRepositoryIntegrationTest {
@Container
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:13.23")
.withDatabaseName("testdb")
.withUsername("testuser")
.withPassword("testpass");
@Autowired
private SubmissionRepository repository;
@Test
void shouldSaveAndRetrieveSubmission() {
SubmissionEntity entity = new SubmissionEntity();
entity.setName("Acme Forestry Corp.");
StepVerifier.create(repository.save(entity))
.assertNext(saved -> assertNotNull(saved.getSubmissionId()))
.verifyComplete();
}
}This wiki serves as the central documentation and knowledge base for the Forests Client Management System, maintained by the British Columbia Ministry of Forests.
Please Note:
- This wiki is a living document maintained by the development team and contributors.
- When making substantial architectural or code changes, remember to update the corresponding wiki documentation.
- Always verify critical environment configurations against team vaults and OpenShift secret managers.
Have questions, found a documentation discrepancy, or need clarification?
- Questions or Bug Reports: Open an issue in the GitHub repository
- Pull Requests: Submit code or doc improvements via Pull Requests
- Database Schema Reference: Explore our SchemaSpy ER Diagrams
Forest Client Wiki | GitHub Repository
- Architecture Overview
- Frontend Architecture
- Frontend Structure
- Backend Architecture
- Backend Structure
- Legacy Architecture
- Processor Architecture
- Data Model
- Development Overview
- Local Setup & Docker
- Frontend Setup
- Backend Setup
- Project Conventions
- Frontend Structure Guidelines