@Before public void initTest() { auditEventRepository.deleteAll(); auditEvent = new PersistentAuditEvent(); auditEvent.setAuditEventType(SAMPLE_TYPE); auditEvent.setPrincipal(SAMPLE_PRINCIPAL); auditEvent.setAuditEventDate(SAMPLE_TIMESTAMP); }
@Test public void getAudit() throws Exception { // Initialize the database auditEventRepository.save(auditEvent); // Get the audit 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 getAllAudits() throws Exception { // Initialize the database auditEventRepository.save(auditEvent); // Get all the audits restAuditMockMvc .perform(get("/api/audits")) .andExpect(status().isOk()) // .andDo(print()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].principal").value(hasItem(SAMPLE_PRINCIPAL))); }
public Optional<AuditEvent> find(Long id) { return Optional.ofNullable(persistenceAuditEventRepository.findOne(id)) .map(auditEventConverter::convertToAuditEvent); }
public List<AuditEvent> findByDates(LocalDateTime fromDate, LocalDateTime toDate) { List<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository.findAllByAuditEventDateBetween(fromDate, toDate); return auditEventConverter.convertToAuditEvent(persistentAuditEvents); }
public List<AuditEvent> findAll() { return auditEventConverter.convertToAuditEvent(persistenceAuditEventRepository.findAll()); }