From 0524a82c09689fab901e4718058f8c68f132d52a Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 8 Dec 2014 16:19:14 -0500 Subject: [PATCH] Update unprocessableEntity to allow body Issue: SPR-12515 --- .../main/java/org/springframework/http/ResponseEntity.java | 2 +- .../java/org/springframework/http/ResponseEntityTests.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java index 638390f13d..1c1f3fe290 100644 --- a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java +++ b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java @@ -252,7 +252,7 @@ public class ResponseEntity extends HttpEntity { * @return the created builder * @since 4.1.3 */ - public static HeadersBuilder unprocessableEntity() { + public static BodyBuilder unprocessableEntity() { return status(HttpStatus.UNPROCESSABLE_ENTITY); } diff --git a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java index a58abf42fd..e4c0f7c84a 100644 --- a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java @@ -122,11 +122,11 @@ public class ResponseEntityTests { @Test public void unprocessableEntity() throws URISyntaxException { - ResponseEntity responseEntity = ResponseEntity.unprocessableEntity().build(); + ResponseEntity responseEntity = ResponseEntity.unprocessableEntity().body("error"); assertNotNull(responseEntity); assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, responseEntity.getStatusCode()); - assertNull(responseEntity.getBody()); + assertEquals("error", responseEntity.getBody()); } @Test