fix(test): use nullValue() matcher instead of doesNotExist() for null note field

doesNotExist() asserts the key is absent from the JSON object, but Jackson
serializes a null Optional<String> as {"note": null} — the key is present with
a null value. nullValue() correctly matches that case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-08 20:50:17 +02:00
parent f9ae6a91ba
commit c31f82a69c

View File

@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -283,7 +284,7 @@ class GeschichteControllerTest {
.contentType(MediaType.APPLICATION_JSON)
.content("{\"note\": null}"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.note").doesNotExist());
.andExpect(jsonPath("$.note").value(nullValue()));
}
@Test