// Force all events to have exact same timestamp:
Date forcedDate = new Date();
EventBuilder builder = eventFactory.getEventBuilder(Event.Target.RULES,
Event.Type.DELETED);
Event rulesDeletedEvent = builder.setOldEntity(new Rules()).buildEvent();
rulesDeletedEvent.setTimestamp(forcedDate);
builder = eventFactory.getEventBuilder(Event.Target.CONSUMER,
Event.Type.CREATED);
Event consumerCreatedEvent = builder.setNewEntity(newConsumer).buildEvent();
consumerCreatedEvent.setTimestamp(forcedDate);
builder = eventFactory.getEventBuilder(Event.Target.CONSUMER,
Event.Type.MODIFIED);
Event consumerModifiedEvent = builder.setNewEntity(newConsumer).
setOldEntity(newConsumer).buildEvent();
consumerModifiedEvent.setTimestamp(forcedDate);
eventCurator.create(rulesDeletedEvent);
eventCurator.create(consumerCreatedEvent);
eventCurator.create(consumerModifiedEvent);
List<Event> mostRecent = eventCurator.listMostRecent(3);
assertEquals(3, mostRecent.size());
// We should see this sorted by timestamp (all the same), then entity, then type:
assertEquals(consumerCreatedEvent.getId(), mostRecent.get(0).getId());
assertEquals(consumerModifiedEvent.getId(), mostRecent.get(1).getId());
assertEquals(rulesDeletedEvent.getId(), mostRecent.get(2).getId());
}