for (int idx = 1; idx <= 10; ++idx) {
events.add(new TestableDomainEvent(idx, "Name: " + idx));
}
EventStreamId eventId = new EventStreamId(UUID.randomUUID().toString());
this.eventStore.appendWith(eventId, events);
EventStream eventStream = this.eventStore.fullEventStreamFor(eventId);
assertEquals(10, eventStream.version());
assertEquals(10, eventStream.events().size());
events.clear();
events.add(new TestableDomainEvent(11, "Name: " + 11));
for (int idx = 0; idx < 3; ++idx) {
try {
this.eventStore.appendWith(eventId.withStreamVersion(8 + idx), events);
fail("Should have thrown an exception.");
} catch (EventStoreAppendException e) {
// good
}
}
// this should succeed
this.eventStore.appendWith(eventId.withStreamVersion(11), events);
}