@Test public void getBook() throws Exception { bookRepository.save(book); restBookMockMvc.perform(get("/app/rest/books/{id}", book.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(book.getId())) .andExpect(jsonPath("$.title").value(DEFAULT_TITLE.toString())) .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())) .andExpect(jsonPath("$.publicationDate").value(DEFAULT_PUBLICATION_DATE.toString())) .andExpect(jsonPath("$.price").value(DEFAULT_PRICE.intValue())); }
@RequestMapping(value = "/rest/books/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Book> get(@PathVariable String id) { log.debug("REST request to get Book : {}", id); return Optional.ofNullable(bookRepository.findOne(id)) .map(book -> new ResponseEntity<>( book, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }
BookResource { @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Book> get(@PathVariable String id) { log.debug("REST request to get Book : {}", id); return Optional.ofNullable(bookRepository.findOne(id)) .map(book -> new ResponseEntity<>( book, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); } }
BookResource { @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Book> get(@PathVariable String id) { log.debug("REST request to get Book : {}", id); return Optional.ofNullable(bookRepository.findOne(id)) .map(book -> new ResponseEntity<>( book, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }  }
BookResource { @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Book> get(@PathVariable String id) { log.debug("REST request to get Book : {}", id); return Optional.ofNullable(bookRepository.findOne(id)) .map(book -> new ResponseEntity<>( book, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }  @RequestMapping(value = "/rest/books", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed void create(@RequestBody Book book); @RequestMapping(value = "/rest/books", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed List<Book> getAll(); @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed ResponseEntity<Book> get(@PathVariable String id); @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Timed void delete(@PathVariable String id); }
BookResource { @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Book> get(@PathVariable String id) { log.debug("REST request to get Book : {}", id); return Optional.ofNullable(bookRepository.findOne(id)) .map(book -> new ResponseEntity<>( book, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }  @RequestMapping(value = "/rest/books", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed void create(@RequestBody Book book); @RequestMapping(value = "/rest/books", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed List<Book> getAll(); @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed ResponseEntity<Book> get(@PathVariable String id); @RequestMapping(value = "/rest/books/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Timed void delete(@PathVariable String id);  }