AuditResource { @RequestMapping(value = "/{id:.+}", method = RequestMethod.GET) public ResponseEntity<AuditEvent> get(@PathVariable Long id) { return auditEventService.find(id) .map((entity) -> new ResponseEntity<>(entity, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); } @Inject  AuditResource(AuditEventService auditEventService); @InitBinder void initBinder(WebDataBinder binder); @RequestMapping(method = RequestMethod.GET) List<AuditEvent> getAll(); @RequestMapping(method = RequestMethod.GET, params = {"fromDate", "toDate"}) List<AuditEvent> getByDates(@RequestParam(value = "fromDate") LocalDateTime fromDate,
                                       @RequestParam(value = "toDate") LocalDateTime toDate); @RequestMapping(value = "/{id:.+}", method = RequestMethod.GET) ResponseEntity<AuditEvent> get(@PathVariable Long id);  }
@Test public void getAllAudits() throws Exception { auditEventRepository.save(auditEvent); restAuditMockMvc.perform(get("/api/audits")).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.[*].principal").value(hasItem(SAMPLE_PRINCIPAL))); }
@Test public void getAudit() throws Exception { auditEventRepository.save(auditEvent); restAuditMockMvc.perform(get("/api/audits/{id}", auditEvent.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.principal").value(SAMPLE_PRINCIPAL)); }
@Test public void getNonExistingAudit() throws Exception { restAuditMockMvc.perform(get("/api/audits/{id}", Long.MAX_VALUE)).andExpect(status().isNotFound()); }