activity.setCreatedAt(t1.toDate());
dao.insert(dbSession, activity);
dbSession.commit();
DateTime t2 = new DateTime().plusHours(1);
assertThat(service.search(new ActivityQuery(),
new QueryContext()).getHits()).hasSize(3);
assertThat(service.search(new ActivityQuery()
.setSince(t0.minusSeconds(5).toDate()),
new QueryContext()).getHits()).hasSize(3);
assertThat(service.search(new ActivityQuery()
.setSince(t1.minusSeconds(5).toDate()),
new QueryContext()).getHits()).hasSize(1);
assertThat(service.search(new ActivityQuery()
.setSince(t2.minusSeconds(5).toDate()),
new QueryContext()).getHits()).hasSize(0);
assertThat(service.search(new ActivityQuery()
.setTo(t1.minusSeconds(5).toDate()),
new QueryContext()).getHits()).hasSize(2);
assertThat(service.search(new ActivityQuery()
.setSince(t1.minusSeconds(5).toDate())
.setTo(t2.plusSeconds(5).toDate()),
new QueryContext()).getHits()).hasSize(1);
}