@Test public void updateABookmarkFailsBecauseDescriptionIsNull() throws Exception { Bookmark input = getSimpleBookmark(); String location = addBookmark(input); Resource<Bookmark> output = getBookmark(location); output.getContent().setDescription(null); mvc.perform( put(output.getId().getHref()) .contentType(MediaType.APPLICATION_JSON_UTF8) .accept("application/hal+json;charset=UTF-8", "application/json;charset=UTF-8") .content(objectMapper.writeValueAsString(output.getContent())) .with(csrf()) ).andDo(print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$[0].field").value("description")); }
@GetMapping("{id}") public Resource<Bookmark> getBookmark(@PathVariable UUID id) { return assembler.toResource(bookmarkService.find(id)); }
BookmarkController { @GetMapping("{id}") public Resource<Bookmark> getBookmark(@PathVariable UUID id) { return assembler.toResource(bookmarkService.find(id)); } }
BookmarkController { @GetMapping("{id}") public Resource<Bookmark> getBookmark(@PathVariable UUID id) { return assembler.toResource(bookmarkService.find(id)); }  }
BookmarkController { @GetMapping("{id}") public Resource<Bookmark> getBookmark(@PathVariable UUID id) { return assembler.toResource(bookmarkService.find(id)); }  @GetMapping("template") Resource<Bookmark> getBookmarkTemplate(); @GetMapping("{id}") Resource<Bookmark> getBookmark(@PathVariable UUID id); @PutMapping("{id}") @PreAuthorize("hasRole('ADMIN')") Resource<Bookmark> updateBookmark(@PathVariable UUID id, @RequestBody @Valid Bookmark bookmark); @DeleteMapping("{id}") @PreAuthorize("hasRole('ADMIN')") ResponseEntity<Void> deleteBookmark(@PathVariable UUID id); }
BookmarkController { @GetMapping("{id}") public Resource<Bookmark> getBookmark(@PathVariable UUID id) { return assembler.toResource(bookmarkService.find(id)); }  @GetMapping("template") Resource<Bookmark> getBookmarkTemplate(); @GetMapping("{id}") Resource<Bookmark> getBookmark(@PathVariable UUID id); @PutMapping("{id}") @PreAuthorize("hasRole('ADMIN')") Resource<Bookmark> updateBookmark(@PathVariable UUID id, @RequestBody @Valid Bookmark bookmark); @DeleteMapping("{id}") @PreAuthorize("hasRole('ADMIN')") ResponseEntity<Void> deleteBookmark(@PathVariable UUID id);  }