fix(mobile-api): event errors use the portal's details/errors contract

The portal forwards only code, errors and flat details from a ProblemDetail, so
the failing field and the TEAM_NOT_SAVED event uuid move into details and the
missing-field list into errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-27 00:25:55 +08:00
1 parent c908fbe9fc
commit 2efdcba1ae
2 files changed
+17 -6

No files matched your search

@@ -107,10 +107,21 @@ class AdminEventServiceTest {
assertThatThrownBy(r::run).isInstanceOfSatisfying(CodedResponseStatusException.class, e -> {
assertThat(e.getStatusCode()).isEqualTo(status);
assertThat(e.getCode()).isEqualTo(code);
if (field != null) assertThat(e.getBody().getProperties()).containsEntry("field", field);
// the portal forwards only code, errors (string list) and details (flat object) from a ProblemDetail
if (field != null) assertThat((Map<String, Object>) e.getBody().getProperties().get("details")).containsEntry("field", field);
});
}
@Test
void create_allMissingFieldsAreListedInErrors() {
assertThatThrownBy(() -> service.create(req("N", " ", null, "", null)))
.isInstanceOfSatisfying(CodedResponseStatusException.class, e -> {
assertThat(e.getCode()).isEqualTo("REQUIRED_FIELD");
assertThat(e.getBody().getProperties().get("errors")).isEqualTo(List.of("location", "startDate", "endDate"));
assertThat((Map<String, Object>) e.getBody().getProperties().get("details")).containsEntry("field", "location");
});
}
private void assertRefusedWithoutSave(AdminEventRequest r, String code, String field) {
assertCoded(() -> service.create(r), HttpStatus.BAD_REQUEST, code, field);
verify(rest, never()).postForEntity(eq(SAVE), any(ParameterizedTypeReference.class), any());
@@ -309,7 +320,7 @@ class AdminEventServiceTest {
.isInstanceOfSatisfying(CodedResponseStatusException.class, e -> {
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_GATEWAY);
assertThat(e.getCode()).isEqualTo("TEAM_NOT_SAVED");
Object uuid = e.getBody().getProperties().get("eventUuid");
Object uuid = ((Map<String, Object>) e.getBody().getProperties().get("details")).get("eventUuid");
assertThat(uuid).isInstanceOf(String.class);
assertThat(e.getReason()).contains((String) uuid);
});