BugController { @RequestMapping( value = "/{bugid}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugDetails.class) public ResponseEntity<Bug> getBug(@PathVariable String bugid) { final StopWatch sw = new StopWatch("GET bug [" + bugid + "]").start(); try { final Bug b = BugRepository.FILTER.findOne(this.bugRepository.findByBugId(bugid)); this.bugRepository.updateCachedCveData(b, false); sw.stop(); return new ResponseEntity<Bug>(b, HttpStatus.OK); } catch (EntityNotFoundException enfe) { sw.stop(enfe); return new ResponseEntity<Bug>(HttpStatus.NOT_FOUND); } catch (Exception e) { sw.stop(e); return new ResponseEntity<Bug>(HttpStatus.INTERNAL_SERVER_ERROR); } } @Autowired  BugController(
      BugRepository bugRepository,
      AffectedLibraryRepository afflibRepository,
      LibraryRepository libRepository,
      TenantRepository tenantRepository); @RequestMapping( value = "", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) Iterable<Bug> getBugs(
      @RequestParam(value = "lang", required = false) ProgrammingLanguage lang); @RequestMapping( value = "/dump", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugDetails.class) Iterable<Bug> getBugAffLibIds(); @RequestMapping( value = "", method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Bug> createBug(@RequestBody Bug bug); @RequestMapping( value = "/dump", method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugDetails.class) ResponseEntity<Bug[]> createAllBugs(@RequestBody Bug[] bugs); @RequestMapping( value = "/{bugid}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugDetails.class) ResponseEntity<Bug> getBug(@PathVariable String bugid); @RequestMapping(value = "/{bugid}", method = RequestMethod.OPTIONS) ResponseEntity<Bug> isBugExisting(@PathVariable String bugid); @RequestMapping( value = "/{bugid}", method = RequestMethod.PUT, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) ResponseEntity<Bug> updateBug(@PathVariable String bugid, @RequestBody Bug bug); @RequestMapping(value = "/{bugid}", method = RequestMethod.DELETE) @CacheEvict(value = "bug") ResponseEntity<Resource<Bug>> deleteBug(@PathVariable String bugid); @RequestMapping( value = "/{bugid}/affectedLibIds", method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugAffLibs.class) ResponseEntity<List<AffectedLibrary>> createAffectedLibrary(
      @PathVariable String bugid,
      @RequestParam(value = "source", required = true) AffectedVersionSource source,
      @RequestBody AffectedLibrary[] affectedLibraries); @RequestMapping( value = "/{bugid}/affectedLibIds", method = RequestMethod.PUT, consumes = {"application/json;charset=UTF-8"}, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugAffLibs.class) ResponseEntity<List<AffectedLibrary>> addAffectedLibrary(
      @PathVariable String bugid,
      @RequestParam(value = "source", required = true) AffectedVersionSource source,
      @RequestBody AffectedLibrary[] affectedLibraries); @RequestMapping( value = "/{bugid}/affectedLibIds", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugAffLibs.class) ResponseEntity<List<AffectedLibrary>> getAllAffectedLibraries(
      @PathVariable String bugid,
      @RequestParam(value = "resolved", required = false, defaultValue = "false") Boolean resolved,
      @RequestParam(value = "source", required = false) AffectedVersionSource source,
      @RequestParam(value = "onlyWellKnown", required = false, defaultValue = "false")
          Boolean onlyWellknown); @RequestMapping( value = "/{bugid}/affectedLibIds/{mvnGroup:.+}/{artifact:.+}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugAffLibsDetails.class) ResponseEntity<List<AffectedLibrary>> getAffectedLibrariesByGA(
      @PathVariable String bugid,
      @PathVariable String mvnGroup,
      @PathVariable String artifact,
      @RequestParam(value = "source", required = false) AffectedVersionSource source); @RequestMapping( value = "/{bugid}/affectedLibIds/{mvnGroup:.+}/{artifact:.+}/{version:.+}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.BugAffLibsDetails.class) ResponseEntity<List<AffectedLibrary>> getAffectedLibraryDetails(
      @PathVariable String bugid,
      @PathVariable String mvnGroup,
      @PathVariable String artifact,
      @PathVariable String version,
      @RequestParam(value = "source", required = false) AffectedVersionSource source); @RequestMapping(value = "/{bugid}/affectedLibIds", method = RequestMethod.OPTIONS) ResponseEntity<List<AffectedLibrary>> areBugAffectedLibrariesExisting(
      @PathVariable String bugid,
      @RequestParam(value = "source", required = true) AffectedVersionSource source); @RequestMapping( value = "/{bugid}/affectedLibIds", method = RequestMethod.DELETE, produces = {"application/json;charset=UTF-8"}) ResponseEntity<List<AffectedLibrary>> deleteAffectedLibraries(
      @PathVariable String bugid,
      @RequestParam(value = "source", required = true) AffectedVersionSource source); @RequestMapping( value = "/{bugid}/libraries", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) ResponseEntity<List<Library>> getAllBugLibraries(@PathVariable String bugid);  }
@Test public void testGetBug() throws Exception { final Bug bug = this.createExampleBug(BUG_ID, BUG_DESCR); this.bugRepository.customSave(bug, true); mockMvc .perform(get("/bugs/" + bug.getBugId())) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$.bugId", is(BUG_ID))) .andExpect(jsonPath("$.reference[0]", is(BUG_URL1))) .andExpect(jsonPath("$.reference[1]", is(BUG_URL2))) .andExpect(jsonPath("$.description", is(BUG_DESCR))); assertEquals(1, this.bugRepository.count()); }