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:de.codecentric.boot.admin.services.SpringBootAdminRegistratorTest.java
@Test public void register_successful() { AdminProperties adminProps = new AdminProperties(); adminProps.setUrl("http://sba:8080"); AdminClientProperties clientProps = new AdminClientProperties(); clientProps.setUrl("http://localhost:8080"); clientProps.setName("AppName"); RestTemplate restTemplate = mock(RestTemplate.class); when(restTemplate.postForEntity(isA(String.class), isA(Application.class), eq(Application.class))) .thenReturn(new ResponseEntity<Application>(HttpStatus.CREATED)); SpringBootAdminRegistrator registrator = new SpringBootAdminRegistrator(restTemplate, adminProps, clientProps);//w w w .ja v a 2s. c o m boolean result = registrator.register(); assertTrue(result); verify(restTemplate).postForEntity("http://sba:8080/api/applications", new Application("http://localhost:8080", "AppName"), Application.class); }
From source file:eu.codesketch.adam.rest.interfaces.SwarmInterface.java
@ResponseBody
@ResponseStatus(code = HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
CreatedSwarmResponseMessage createNewSwarm(CreateSwarmRequestMessage message);
From source file:com.envision.envservice.rest.PushConfigResource.java
@SuppressWarnings("rawtypes") @POST// w ww .j av a2s .co m @Path("/addPushConfig") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addPushConfig(PushConfigBo pushConfigBo) throws Exception { HttpStatus status = HttpStatus.CREATED; Map response = pcService.addPushConfig(pushConfigBo); return Response.status(status.value()).entity(response).build(); }
From source file:be.bittich.quote.controller.impl.UserController.java
@Override @RequestMapping(value = "/create", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public User create(@RequestBody @Valid User t) { if (t.getId() != null && getService().findOneById(t.getId()) != null) { throw new EntityExistException("Ajout impossible : l'entit existe dj!"); }/*from w w w . j a v a 2 s . c o m*/ Role roleDefault = factoryService.roleService().findByRoleName(ROLE_USER); t.addRole(roleDefault); return this.getService().insert(t); }
From source file:com.tribuo.backend.controllers.EspecificosController.java
/** * * @param p//ww w.jav a 2 s. c om * @return */ @RequestMapping(value = "/insert", method = RequestMethod.POST) public ResponseEntity<Void> insertSubcategoria(@RequestBody Especificos p) { se.insertEspecifico(p); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:org.openbaton.autoscaling.api.RestEventInterface.java
/** * Activates autoscaling for the passed NSR * * @param msg : NSR in payload to add for autoscaling *//*from w w w . jav a2s .co m*/ @RequestMapping(value = "INSTANTIATE_FINISH", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public void activate(@RequestBody String msg) throws NotFoundException, VimException, SDKException { log.debug("========================"); log.debug("msg=" + msg); JsonParser jsonParser = new JsonParser(); JsonObject json = jsonParser.parse(msg).getAsJsonObject(); Gson mapper = new GsonBuilder().create(); Action action = mapper.fromJson(json.get("action"), Action.class); log.debug("ACTION=" + action); NetworkServiceRecord nsr = mapper.fromJson(json.get("payload"), NetworkServiceRecord.class); log.debug("NSR=" + nsr); elasticityManagement.activate(nsr.getId()); }
From source file:com.example.todo.api.todo.TodoRestController.java
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public TodoResource postTodos(@RequestBody @Validated TodoResource todoResource) { Todo createdTodo = todoService.create(beanMapper.map(todoResource, Todo.class)); TodoResource createdTodoResponse = beanMapper.map(createdTodo, TodoResource.class); return createdTodoResponse; }
From source file:sample.SpringDataRestDeleteNotFoundApplicationTests.java
@Test public void messagesCrud() { Message toCreate = createMessage();/* w w w . j a va 2 s . co m*/ ResponseEntity<Message> created = rest.postForEntity("/messages/", toCreate, Message.class); assertThat(created).isNotNull(); assertThat(created.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(created.getBody().getText()).isEqualTo(toCreate.getText()); URI createdUri = created.getHeaders().getLocation(); Message getForEntity = rest.getForEntity(createdUri, Message.class).getBody(); assertThat(getForEntity.getText()).isEqualTo(toCreate.getText()); // response is 405 when @GetMapping("/messages/{id}") is present rest.delete(createdUri); assertThat(rest.getForEntity(createdUri, Message.class).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); }
From source file:com.envision.envservice.rest.UserCasePriseResource.java
@GET @Path("/user/{userId}") @Produces(MediaType.APPLICATION_JSON)// ww w. j a v a 2 s.c o m public Response queryPriseCollect(@PathParam("userId") String userId) { HttpStatus status = HttpStatus.CREATED; String response = userCasePriseService.queryPriseCollect(userId).toJSONString(); return Response.status(status.value()).entity(response).build(); }
From source file:com.parivero.swagger.demo.controller.PaisController.java
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody Pais alta(@RequestBody Pais pais) { if (pais.getId() != null) { throw new IllegalArgumentException(); }//from ww w . j a va 2 s . c o m pais.setId(Long.MAX_VALUE); pais.setNombre(pais.getNombre() + "- Creado"); return pais; }