Beispiel #1
0
  private void performQuery(AuditQuery<Audit> query, List<Long> expected) throws SQLException {

    InMemoryAuditDao dao = new InMemoryAuditDao();
    dao.saveAll(getAudits());

    List<Audit> result = dao.doQuery(query);
    Set<Long> ids = new HashSet<>();
    for (Audit audit : result) {
      ids.add(audit.getId());
    }
    assertEquals(new HashSet<>(expected), new HashSet<>(ids));
  }
Beispiel #2
0
  private static List<Audit> getAudits() {
    List<Audit> audits = new ArrayList<>();
    int i = 0;

    Audit randomAudit;
    randomAudit = ModelGenerator.randomAudit();
    randomAudit.setId(i++);
    randomAudit.setUsername("earlier");
    randomAudit.setDate(earlier);
    randomAudit.setAccessType(AccessType.CREATE);
    randomAudit.setAction("create");
    randomAudit.setElementAccessed(randomAudit.getAccessType().name());
    audits.add(randomAudit);

    randomAudit = ModelGenerator.randomAudit();
    randomAudit.setId(i++);
    randomAudit.setDate(current);
    randomAudit.setUsername("current");
    randomAudit.setAccessType(AccessType.READ);
    randomAudit.setAction("read");
    randomAudit.setElementAccessed(randomAudit.getAccessType().name());
    audits.add(randomAudit);

    randomAudit = ModelGenerator.randomAudit();
    randomAudit.setId(i++);
    randomAudit.setDate(later);
    randomAudit.setUsername("later");
    randomAudit.setAccessType(AccessType.UPDATE);
    randomAudit.setAction("update");
    randomAudit.setElementAccessed(randomAudit.getAccessType().name());
    audits.add(randomAudit);

    randomAudit = ModelGenerator.randomAudit();
    randomAudit.setId(i++);
    randomAudit.setDate(current);
    randomAudit.setUsername("current");
    randomAudit.setAccessType(AccessType.DELETE);
    randomAudit.setAction("delete");
    randomAudit.setElementAccessed(randomAudit.getAccessType().name());
    audits.add(randomAudit);

    randomAudit = ModelGenerator.randomAudit();
    randomAudit.setId(i++);
    randomAudit.setDate(current);
    randomAudit.setUsername("current");
    randomAudit.setAccessType(AccessType.CREATE);
    randomAudit.setAction("create");
    randomAudit.setElementAccessed(randomAudit.getAccessType().name());
    audits.add(randomAudit);

    return audits;
  }