ClusterNodeController extends AbstractOhfController { @RequestMapping(value = "/{id}", method = RequestMethod.PUT, produces = {"application/xml", "application/json"}) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public void update(@PathVariable final Long id, @RequestBody @Valid final NodeRpc nodeRpc, BindingResult errors) throws ValidationException, NoDataFoundException { Assert.notNull(nodeRpc, "nodeRpc can not be null"); if (nodeRpc.getId() != null) { Constraints.state(id.equals(nodeRpc.getId()), "IDs must be equal"); } Node dbNode = nodeService.getNodeById(id); nodeService.update(dbNode, new NodeRpc.ChangeCallback(errors, nodeRpc)); }  @RequestMapping(method = RequestMethod.GET, produces = {"application/xml", "application/json"}) @ResponseStatus(HttpStatus.OK) @ResponseBody CollectionWrapper<NodeRpc> findAll(); @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = {"application/xml", "application/json"}) @ResponseStatus(HttpStatus.OK) @ResponseBody NodeRpc getById(@PathVariable final Long id); @RequestMapping(value = "/{id}", method = RequestMethod.PUT, produces = {"application/xml", "application/json"}) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody void update(@PathVariable final Long id, @RequestBody @Valid final NodeRpc nodeRpc,
            BindingResult errors); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = {"application/xml", "application/json"}) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody void delete(@PathVariable final Long id); static final String REST_URI; }
@Test public void testUpdate() throws Exception { final URIBuilder uriBuilder = createGetUrl(ROOT_URI + "/" + firstNode.getId()); JsonObject request = createJson() .add("name", "updatedFirstNode") .add("description", "updated") .add("state", "STOPPED") .build(); mockMvc.perform(put(toUrl(uriBuilder)) .content(request.toString()) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON) .with(SecurityMockMvcRequestPostProcessors.authentication(mockAuthentication("ADMIN")))) .andExpect(status().isNoContent()) .andExpect(content().string(isEmptyString())); Node tested = nodeService.getNodeById(firstNode.getId()); assertThat(tested.getName(), is("updatedFirstNode")); assertThat(tested.getDescription(), is("updated")); assertThat(tested.getState(), is(NodeState.STOPPED)); }