@Test public void getEventsIgnoresNegativeCount() { ArgumentCaptor<Criterion> criterion = ArgumentCaptor.forClass(Criterion.class); Calendar from = Calendar.getInstance(); Calendar to = Calendar.getInstance(); AuditEvent eventTemplate = new AuditEvent(this.user, "127.0.0.1", "action", null, null, null); this.store.getEvents(eventTemplate, from, to, 0, -25); Mockito.verify(this.criteria, Mockito.times(2)).add(criterion.capture()); Example ex = (Example) criterion.getAllValues().get(0); Assert.assertEquals("example (wiki:XWiki.user (127.0.0.1): action on null at null)", ex.toString()); BetweenExpression between = (BetweenExpression) criterion.getAllValues().get(1); Assert.assertEquals("time between " + from.toString() + " and " + to.toString(), between.toString()); Mockito.verify(this.criteria, Mockito.never()).setMaxResults(Matchers.anyInt()); }
private List<AuditEvent> getEvents(User user, String ip, String type, DocumentReference entity) { return getEvents(new AuditEvent(user, ip, type, null, entity, null), null, null, 0, 0); }
HibernateAuditStore implements AuditStore { private List<AuditEvent> getEvents(User user, String ip, String type, DocumentReference entity) { return getEvents(new AuditEvent(user, ip, type, null, entity, null), null, null, 0, 0); } }
HibernateAuditStore implements AuditStore { private List<AuditEvent> getEvents(User user, String ip, String type, DocumentReference entity) { return getEvents(new AuditEvent(user, ip, type, null, entity, null), null, null, 0, 0); }  }
HibernateAuditStore implements AuditStore { private List<AuditEvent> getEvents(User user, String ip, String type, DocumentReference entity) { return getEvents(new AuditEvent(user, ip, type, null, entity, null), null, null, 0, 0); }  @Override void store(AuditEvent event); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity, String type); @Override List<AuditEvent> getEventsForUser(User user); @Override List<AuditEvent> getEventsForUser(User user, String ip); @Override List<AuditEvent> getEventsForUser(User user, String ip, String type); @Override List<AuditEvent> getEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime, int start,
        int maxResults); @Override long countEventsForEntity(DocumentReference entity); @Override long countEventsForEntity(DocumentReference entity, String type); @Override long countEventsForUser(User user); @Override long countEventsForUser(User user, String ip); @Override long countEventsForUser(User user, String ip, String type); @Override long countEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime); }
HibernateAuditStore implements AuditStore { private List<AuditEvent> getEvents(User user, String ip, String type, DocumentReference entity) { return getEvents(new AuditEvent(user, ip, type, null, entity, null), null, null, 0, 0); }  @Override void store(AuditEvent event); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity); @Override List<AuditEvent> getEventsForEntity(DocumentReference entity, String type); @Override List<AuditEvent> getEventsForUser(User user); @Override List<AuditEvent> getEventsForUser(User user, String ip); @Override List<AuditEvent> getEventsForUser(User user, String ip, String type); @Override List<AuditEvent> getEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime, int start,
        int maxResults); @Override long countEventsForEntity(DocumentReference entity); @Override long countEventsForEntity(DocumentReference entity, String type); @Override long countEventsForUser(User user); @Override long countEventsForUser(User user, String ip); @Override long countEventsForUser(User user, String ip, String type); @Override long countEvents(AuditEvent eventTemplate, Calendar fromTime, Calendar toTime);  }