diff --git a/CLAUDE.md b/CLAUDE.md index 639dd2ba..bba08400 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -86,7 +86,8 @@ backend/src/main/java/org/raddatz/familienarchiv/ │ └── transcription/ TranscriptionBlock, TranscriptionService, TranscriptionBlockQueryService ├── exception/ DomainException, ErrorCode, GlobalExceptionHandler ├── filestorage/ FileService (S3/MinIO) -├── geschichte/ Geschichte (story) domain +├── geschichte/ Geschichte (story) domain — GeschichteService, GeschichteQueryService +│ └── journeyitem/ JourneyItem sub-domain — JourneyItemService, JourneyItemController ├── importing/ CanonicalImportOrchestrator + four loaders (TagTree/PersonRegister/PersonTree/Document) + CanonicalSheetReader ├── notification/ Notification domain + SseEmitterRegistry ├── ocr/ OCR domain — OcrService, OcrBatchService, training diff --git a/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemService.java b/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemService.java index e05382ec..5b83af6a 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemService.java @@ -47,14 +47,14 @@ public class JourneyItemService { "Journey not found: " + geschichteId)); if (g.getType() != GeschichteType.JOURNEY) { - throw DomainException.badRequest(ErrorCode.VALIDATION_ERROR, - "Geschichte is not a JOURNEY — cannot append items"); + throw DomainException.conflict(ErrorCode.GESCHICHTE_TYPE_MISMATCH, + "Journey items can only be added to a JOURNEY-type Geschichte"); } long count = journeyItemRepository.countByGeschichteId(geschichteId); if (count >= MAX_ITEMS) { - throw DomainException.badRequest(ErrorCode.VALIDATION_ERROR, - "Journey already has the maximum of " + MAX_ITEMS + " items"); + throw DomainException.conflict(ErrorCode.JOURNEY_AT_CAPACITY, + "Journey has reached the maximum of 100 items"); } String note = normalizeNote(dto.getNote()); diff --git a/backend/src/test/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemServiceTest.java index f3d9a97f..14e299d9 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemServiceTest.java @@ -221,7 +221,7 @@ class JourneyItemServiceTest { } @Test - void append_returns400_on_non_JOURNEY_type() { + void append_returns409_on_non_JOURNEY_type() { Geschichte story = Geschichte.builder() .id(geschichteId) .title("Story") @@ -236,7 +236,7 @@ class JourneyItemServiceTest { assertThatThrownBy(() -> journeyItemService.append(geschichteId, dto)) .isInstanceOf(DomainException.class) .satisfies(e -> assertThat(((DomainException) e).getCode()) - .isEqualTo(ErrorCode.VALIDATION_ERROR)); + .isEqualTo(ErrorCode.GESCHICHTE_TYPE_MISMATCH)); } @Test @@ -257,7 +257,7 @@ class JourneyItemServiceTest { } @Test - void append_returns400_when_100_items_exist() { + void append_returns409_when_100_items_exist() { Geschichte journey = journey(geschichteId); when(geschichteRepository.findById(geschichteId)).thenReturn(Optional.of(journey)); when(journeyItemRepository.countByGeschichteId(geschichteId)).thenReturn(100L); @@ -268,7 +268,7 @@ class JourneyItemServiceTest { assertThatThrownBy(() -> journeyItemService.append(geschichteId, dto)) .isInstanceOf(DomainException.class) .satisfies(e -> assertThat(((DomainException) e).getCode()) - .isEqualTo(ErrorCode.VALIDATION_ERROR)); + .isEqualTo(ErrorCode.JOURNEY_AT_CAPACITY)); } @Test