@Test public void update() throws Exception { mockMvc.perform(put("/foos/{id}", "foo") .content("{\"uuid\":\"foo\",\"name\":\"Sample Foo\"}") .contentType("application/hal+json")) .andDo(print()) .andExpect(status().isOk()); }
@PutMapping("/{id}") public HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource) { log.info("Update {} : {}", id, fooResource); Foo entity = new Foo(fooResource.getUuid(), fooResource.getName()); return ResponseEntity.ok(assembler.toModel(entity)); }
FooController { @PutMapping("/{id}") public HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource) { log.info("Update {} : {}", id, fooResource); Foo entity = new Foo(fooResource.getUuid(), fooResource.getName()); return ResponseEntity.ok(assembler.toModel(entity)); } }
FooController { @PutMapping("/{id}") public HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource) { log.info("Update {} : {}", id, fooResource); Foo entity = new Foo(fooResource.getUuid(), fooResource.getName()); return ResponseEntity.ok(assembler.toModel(entity)); } FooController(FooResourceAssembler assembler); }
FooController { @PutMapping("/{id}") public HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource) { log.info("Update {} : {}", id, fooResource); Foo entity = new Foo(fooResource.getUuid(), fooResource.getName()); return ResponseEntity.ok(assembler.toModel(entity)); } FooController(FooResourceAssembler assembler); @GetMapping("/{id}") HttpEntity<FooResource> get(@PathVariable UUID id); @PutMapping("/{id}") HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource); @PostMapping HttpEntity<FooResource> create(@RequestBody FooResource fooResource); }
FooController { @PutMapping("/{id}") public HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource) { log.info("Update {} : {}", id, fooResource); Foo entity = new Foo(fooResource.getUuid(), fooResource.getName()); return ResponseEntity.ok(assembler.toModel(entity)); } FooController(FooResourceAssembler assembler); @GetMapping("/{id}") HttpEntity<FooResource> get(@PathVariable UUID id); @PutMapping("/{id}") HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource); @PostMapping HttpEntity<FooResource> create(@RequestBody FooResource fooResource);  }