@@ -311,7 +311,31 @@ void shouldReturnBadRequestForInvalidTodoUpdate() {
311311 assertThat (response .getBody ().get ("violations" ).get (0 ).get ("defaultMessage" )).isEqualTo (
312312 new TextNode ("The size of \" todoTitle\" must be less than or equal to 255. The given size is 256" ));
313313 assertThat (response .getBody ().get ("violations" ).get (1 ).get ("defaultMessage" ))
314- .isEqualTo (new TextNode ("\" finished\" must be one of the following values: [false, true]" ));
314+ .isEqualTo (new TextNode ("\" finished\" must be one of the following values: [true, false]" ));
315+ }
316+
317+ @ Test
318+ @ Order (4 )
319+ void shouldReturnBadRequestForNullTodoUpdate () {
320+ String accessToken = this .accessTokenSupplier .apply (Set .of ("todo:write" ));
321+ ResponseEntity <JsonNode > response = this .restClient .patch ()
322+ .uri ("/todos/{todoId}" , "00000000-0000-0000-0000-000000000001" )
323+ .contentType (MediaType .APPLICATION_JSON )
324+ .body ("""
325+ {}
326+ """ )
327+ .headers (httpHeaders -> httpHeaders .setBearerAuth (accessToken ))
328+ .retrieve ()
329+ .toEntity (JsonNode .class );
330+ assertThat (response .getStatusCode ()).isEqualTo (HttpStatus .BAD_REQUEST );
331+ assertThat (response .getBody ()).isNotNull ();
332+ assertThat (response .getBody ().get ("message" )).isEqualTo (new TextNode ("Validation failed" ));
333+ assertThat (response .getBody ().has ("violations" )).isTrue ();
334+ assertThat (response .getBody ().get ("violations" ).size ()).isEqualTo (2 );
335+ assertThat (response .getBody ().get ("violations" ).get (0 ).get ("defaultMessage" ))
336+ .isEqualTo (new TextNode ("\" todoTitle\" must not be blank" ));
337+ assertThat (response .getBody ().get ("violations" ).get (1 ).get ("defaultMessage" ))
338+ .isEqualTo (new TextNode ("\" finished\" must not be null" ));
315339 }
316340
317341 @ Test
0 commit comments