fix(journeyitem): use specific error codes in append() — JOURNEY_AT_CAPACITY and GESCHICHTE_TYPE_MISMATCH
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m21s
CI / OCR Service Tests (pull_request) Successful in 22s
CI / Backend Unit Tests (pull_request) Successful in 3m56s
CI / fail2ban Regex (pull_request) Successful in 46s
CI / Semgrep Security Scan (pull_request) Successful in 22s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m5s

- JourneyItemService.append(): replace VALIDATION_ERROR with GESCHICHTE_TYPE_MISMATCH (409 conflict)
  for non-JOURNEY type guard and JOURNEY_AT_CAPACITY (409 conflict) for 100-item cap
- JourneyItemServiceTest: update assertions to expect the new specific error codes
- CLAUDE.md: expand geschichte/ package table entry with GeschichteQueryService and journeyitem/ sub-domain

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-08 19:31:30 +02:00
parent c5611250ec
commit 598ad622e7
3 changed files with 10 additions and 9 deletions

View File

@@ -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());

View File

@@ -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