test(backend): add service unit tests and controller slice tests #5

Merged
marcel merged 2 commits from devops/backend-tests into main 2026-03-17 21:39:07 +01:00
Owner

Summary

  • Service unit tests (Mockito, no Spring context): DocumentService, PersonService, TagService, UserService — covering not-found errors, business logic branches, and cascading operations
  • Controller slice tests (@WebMvcTest): DocumentController and TagController — verifying 401 (unauthenticated), 403 (wrong permission via PermissionAspect), and 200 (happy path) for every protected endpoint
  • Removes FamilienarchivApplicationTests — the full @SpringBootTest context load requires DB + S3; that coverage is owned by the e2e job

65 tests total, all passing.

Notable Spring Boot 4.0 quirks solved:

  • @WebMvcTest moved to org.springframework.boot.webmvc.test.autoconfigure
  • SecurityConfig must be explicitly @Imported (CSRF disabled)
  • AopAutoConfiguration must be @Imported for PermissionAspect to fire

Closes #4

## Summary - **Service unit tests** (Mockito, no Spring context): `DocumentService`, `PersonService`, `TagService`, `UserService` — covering not-found errors, business logic branches, and cascading operations - **Controller slice tests** (`@WebMvcTest`): `DocumentController` and `TagController` — verifying 401 (unauthenticated), 403 (wrong permission via `PermissionAspect`), and 200 (happy path) for every protected endpoint - Removes `FamilienarchivApplicationTests` — the full `@SpringBootTest` context load requires DB + S3; that coverage is owned by the e2e job **65 tests total, all passing.** Notable Spring Boot 4.0 quirks solved: - `@WebMvcTest` moved to `org.springframework.boot.webmvc.test.autoconfigure` - `SecurityConfig` must be explicitly `@Import`ed (CSRF disabled) - `AopAutoConfiguration` must be `@Import`ed for `PermissionAspect` to fire Closes #4
marcel added 1 commit 2026-03-17 21:33:55 +01:00
test(backend): add service unit tests and controller slice tests
Some checks failed
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (push) Has started running
CI / E2E Tests (pull_request) Has been cancelled
CI / Unit & Component Tests (pull_request) Has been cancelled
225d6e44c9
Service unit tests (Mockito, no Spring context):
- DocumentServiceTest — getById, updateDocument, deleteTagCascading, createPlaceholder
- PersonServiceTest — getById, findOrCreateByAlias, mergePersons
- TagServiceTest — getById, findOrCreate, update, delete
- UserServiceTest — findByUsername, deleteUser, createUserOrUpdate, getGroupById

Controller slice tests (@WebMvcTest):
- DocumentControllerTest — 401/403/200 for GET /search, POST /, PUT /{id}
- TagControllerTest — 401/403/200 for GET, PUT /{id}, DELETE /{id}

Also removes FamilienarchivApplicationTests (full @SpringBootTest
requires DB + S3 infrastructure; covered by e2e job instead).

65 tests total, all passing.
Refs #4

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel added 1 commit 2026-03-17 21:37:54 +01:00
ci: add backend unit test job to pipeline
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Backend Unit Tests (pull_request) Has been cancelled
CI / E2E Tests (pull_request) Has been cancelled
CI / Unit & Component Tests (pull_request) Has been cancelled
3f987ca48f
Runs ./mvnw clean test in a dedicated job — no DB or S3 needed
since all tests use Mockito or WebMvcTest slices.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel merged commit 3f987ca48f into main 2026-03-17 21:39:07 +01:00
marcel deleted branch devops/backend-tests 2026-03-17 21:39:08 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#5