提交 1daa5eb3 编写于 作者: J Juergen Hoeller

ResponseEntity provides static "unprocessableEntity()" convenience method as well

Issue: SPR-12515
上级 03f5176d
......@@ -246,6 +246,16 @@ public class ResponseEntity<T> extends HttpEntity<T> {
return status(HttpStatus.NOT_FOUND);
}
/**
* Create a builder with an
* {@linkplain HttpStatus#UNPROCESSABLE_ENTITY UNPROCESSABLE_ENTITY} status.
* @return the created builder
* @since 4.1.3
*/
public static HeadersBuilder<?> unprocessableEntity() {
return status(HttpStatus.UNPROCESSABLE_ENTITY);
}
/**
* Defines a builder that adds headers to the response entity.
......
......@@ -26,6 +26,7 @@ import static org.junit.Assert.*;
/**
* @author Arjen Poutsma
* @author Marcel Overdijk
*/
public class ResponseEntityTests {
......@@ -119,6 +120,15 @@ public class ResponseEntityTests {
assertNull(responseEntity.getBody());
}
@Test
public void unprocessableEntity() throws URISyntaxException {
ResponseEntity<Void> responseEntity = ResponseEntity.unprocessableEntity().build();
assertNotNull(responseEntity);
assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, responseEntity.getStatusCode());
assertNull(responseEntity.getBody());
}
@Test
public void headers() throws URISyntaxException {
String eTag = "\"foo\"";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册