List of usage examples for org.springframework.http HttpStatus CREATED
HttpStatus CREATED
To view the source code for org.springframework.http HttpStatus CREATED.
Click Source Link
From source file:com.salmon.security.xacml.demo.springmvc.rest.HTTPPopulatorsTest.java
@Test public void testCreateDriver() { ResponseEntity<Driver> entity = this.createOneDriver(); String path = entity.getHeaders().getLocation().getPath(); assertEquals(HttpStatus.CREATED, entity.getStatusCode()); Driver driver = entity.getBody(); LOG.info("The Driver ID is " + driver.getInternalID()); LOG.info("The Location is " + entity.getHeaders().getLocation()); LOG.info("The Path is " + path); assertEquals("JOEBOGGS2015LICENSE", driver.getDriversLicense()); assertTrue(path.startsWith("/xacml/aggregators/dvla/drivers/")); }
From source file:com.ge.predix.acs.commons.web.ResponseEntityBuilder.java
/** * Creates a typed ResponseEntity with HTTP status code 201/204 with a given location. * * @param location// w ww .j a v a 2s . c o m * The location of the created resource * @param noContent * false means updated resource which returns 204, true means created resource which returns 201 * @return The corresponding ResponseEntity */ public static <T> ResponseEntity<T> created(final String location, final boolean noContent) { HttpStatus status = noContent ? HttpStatus.NO_CONTENT : HttpStatus.CREATED; if (location != null) { HttpHeaders headers = new HttpHeaders(); headers.setLocation(URI.create(location)); return new ResponseEntity<T>(headers, status); } return new ResponseEntity<T>(status); }
From source file:com.grizzly.rest.Definitions.DefinitionsHttpMethods.java
/** * Returns the http states currently supported. * @return a List of int representing the supported http states. *//*from w w w. j a v a2s . c o m*/ public static List<Integer> getHttpStates() { List<Integer> list = new ArrayList<>(); list.add(HttpStatus.OK.value()); list.add(HttpStatus.ACCEPTED.value()); list.add(HttpStatus.CREATED.value()); return list; }
From source file:com.recursivechaos.clearent.controller.SaleControllerTest.java
@Test public void testPostSale() throws Exception { Sale saleRequest = TestUtil.createSaleRequest(); when(saleService.createSale(saleRequest)).thenReturn(saleRequest); URI uri = new URI("/sales/1"); when(responseService.getLocationUri(saleRequest)).thenReturn(uri); ResponseEntity<Void> responseEntity = saleController.postSale(saleRequest); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertEquals("/sales/1", responseEntity.getHeaders().getLocation().getPath()); }
From source file:com.github.wnameless.spring.papertrail.test.jpa.JpaTestController.java
@RequestMapping(value = "/around", method = RequestMethod.POST) @ResponseBody @ResponseStatus(HttpStatus.CREATED) String around() { return "around"; }
From source file:demo.ServiceLocationBulkUploadController.java
@RequestMapping(value = "/bulk/serviceLocations", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void upload(@RequestBody List<ServiceLocation> locations) { this.repository.save(locations); }
From source file:com.mycompany.geocoordinate.controller.PolygonController.java
@ResponseStatus(HttpStatus.CREATED) @PostMapping(value = "/polygon", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public @ResponseBody ResponseEntity<List<Integer>> polygon(@RequestBody GeoObject geoObject) throws IOException, JsonException { boolean check = coordinateMapper.isThereGeoObjectFromPolygontype(GeoType.POLYGON) != null & coordinateMapper.selectCoordinateForLineorCircle(geoObject.getCoordinate()) != null; coordinateMapper.insertCoordinateForLineorCircle(GeoType.POLYGON, geoObject.getCoordinate()); List<Integer> responseType = coordinateMapper.selectIdGeo(geoObject.getCoordinate()); return ResponseEntity.created(URI.create("/polygon/id")).body(responseType); }
From source file:com.tsg.contactlistmvc.RESTController.java
@RequestMapping(value = "/contact", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) @ResponseBody// w ww.ja v a2s . c o m public Contact createContact(@Valid @RequestBody Contact contact) { return dao.addContact(contact); }
From source file:rest.JugadorRestController.java
@RequestMapping(value = "/{id}", method = RequestMethod.PUT) public ResponseEntity<?> modificarJugador(@PathVariable int id, @RequestBody Jugador j) { logicaJugador.modificarJugador(j, id); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:com.recursivechaos.clearent.controller.SaleControllerIntegrationTest.java
@Test public void testPostSale() throws Exception { Sale saleRequest = TestUtil.createSaleRequest(); ResponseEntity<Void> responseEntity = saleController.postSale(saleRequest); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertEquals("/sales/1", responseEntity.getHeaders().getLocation().getPath()); }