test(backend): add service unit tests and controller slice tests #5
Reference in New Issue
Block a user
Delete Branch "devops/backend-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
DocumentService,PersonService,TagService,UserService— covering not-found errors, business logic branches, and cascading operations@WebMvcTest):DocumentControllerandTagController— verifying 401 (unauthenticated), 403 (wrong permission viaPermissionAspect), and 200 (happy path) for every protected endpointFamilienarchivApplicationTests— the full@SpringBootTestcontext load requires DB + S3; that coverage is owned by the e2e job65 tests total, all passing.
Notable Spring Boot 4.0 quirks solved:
@WebMvcTestmoved toorg.springframework.boot.webmvc.test.autoconfigureSecurityConfigmust be explicitly@Imported (CSRF disabled)AopAutoConfigurationmust be@Imported forPermissionAspectto fireCloses #4
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 referenced this pull request2026-04-25 17:00:44 +02:00