io.agistep.event.test.EventFixtureBuilder Maven / Gradle / Ivy
The newest version!
package io.agistep.event.test;
import io.agistep.aggregator.IdUtils;
import io.agistep.event.Event;
import io.agistep.event.EventMaker;
import io.agistep.event.EventSource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import static io.agistep.event.EventMaker.*;
import static io.agistep.event.EventSource.INITIAL_SEQ;
import static org.hamcrest.CoreMatchers.*;
import static org.valid4j.Validation.validate;
public final class EventFixtureBuilder {
public static Event anEventWith(Object firstPayload) {
return anEventWith(getId(), firstPayload);
}
public static Event anEventWith(long aggregateId, Object firstPayload) {
return new EventFixtureBuilder(aggregateId, firstPayload).build()[0];
}
public static EventFixtureBuilder eventsWith(Object firstPayload) {
return new EventFixtureBuilder(getId(), firstPayload);
}
private static long getId() {
return IdUtils.gen();
}
public static EventFixtureBuilder eventsWith(long aggregateId, Object firstPayload) {
return new EventFixtureBuilder(aggregateId, firstPayload);
}
private final long aggregateId;
private final List