new ConsumerType("system"));
consumerTypeCurator.create(newConsumer.getType());
consumerCurator.create(newConsumer);
setupPrincipal(owner, Access.ALL);
EventFactory eventFactory = injector.getInstance(EventFactory.class);
// 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);