Search in sources :

Example 1 with AggregateEventRecord

use of io.spine.server.aggregate.AggregateEventRecord in project core-java by SpineEventEngine.

the class StorageRecord method create.

public static AggregateEventRecord create(Timestamp timestamp) {
    final Message eventMessage = Sample.messageOfType(AggProjectCreated.class);
    final Event event = eventFactory.createEvent(eventMessage);
    final AggregateEventRecord.Builder builder = AggregateEventRecord.newBuilder().setTimestamp(timestamp).setEvent(event);
    return builder.build();
}
Also used : AggregateEventRecord(io.spine.server.aggregate.AggregateEventRecord) Message(com.google.protobuf.Message) Event(io.spine.core.Event)

Example 2 with AggregateEventRecord

use of io.spine.server.aggregate.AggregateEventRecord in project core-java by SpineEventEngine.

the class StorageRecords method sequenceFor.

/**
 * Returns several records sorted by timestamp ascending.
 *
 * @param start the timestamp of first record.
 */
public static List<AggregateEventRecord> sequenceFor(ProjectId id, Timestamp start) {
    final Duration delta = seconds(10);
    final Timestamp timestamp2 = add(start, delta);
    final Timestamp timestamp3 = add(timestamp2, delta);
    final TestEventFactory eventFactory = newInstance(Given.class);
    final Event e1 = eventFactory.createEvent(projectCreated(id, Given.projectName(id)), null, start);
    final AggregateEventRecord record1 = StorageRecord.create(start, e1);
    final Event e2 = eventFactory.createEvent(taskAdded(id), null, timestamp2);
    final AggregateEventRecord record2 = StorageRecord.create(timestamp2, e2);
    final Event e3 = eventFactory.createEvent(Given.EventMessage.projectStarted(id), null, timestamp3);
    final AggregateEventRecord record3 = StorageRecord.create(timestamp3, e3);
    return newArrayList(record1, record2, record3);
}
Also used : AggregateEventRecord(io.spine.server.aggregate.AggregateEventRecord) TestEventFactory(io.spine.server.command.TestEventFactory) Event(io.spine.core.Event) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp)

Aggregations

Event (io.spine.core.Event)2 AggregateEventRecord (io.spine.server.aggregate.AggregateEventRecord)2 Duration (com.google.protobuf.Duration)1 Message (com.google.protobuf.Message)1 Timestamp (com.google.protobuf.Timestamp)1 TestEventFactory (io.spine.server.command.TestEventFactory)1