use of io.spine.server.event.EventFactory in project core-java by SpineEventEngine.
the class EventsShould method setUp.
@Before
public void setUp() {
final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
final CommandEnvelope cmd = requestFactory.generateEnvelope();
final StringValue producerId = toMessage(getClass().getSimpleName());
EventFactory eventFactory = EventFactory.on(cmd, Identifier.pack(producerId));
event = eventFactory.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
context = event.getContext();
}
use of io.spine.server.event.EventFactory in project core-java by SpineEventEngine.
the class EventsShould method obtain_type_name_of_event.
@Test
public void obtain_type_name_of_event() {
final CommandEnvelope command = requestFactory.generateEnvelope();
final StringValue producerId = toMessage(getClass().getSimpleName());
final EventFactory ef = EventFactory.on(command, Identifier.pack(producerId));
final Event event = ef.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
final TypeName typeName = EventEnvelope.of(event).getTypeName();
assertNotNull(typeName);
assertEquals(Timestamp.class.getSimpleName(), typeName.getSimpleName());
}
use of io.spine.server.event.EventFactory in project core-java by SpineEventEngine.
the class EventsShould method obtain_root_command_id.
@Test
public void obtain_root_command_id() {
final CommandEnvelope command = requestFactory.generateEnvelope();
final StringValue producerId = toMessage(getClass().getSimpleName());
final EventFactory ef = EventFactory.on(command, Identifier.pack(producerId));
final Event event = ef.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
assertEquals(command.getId(), Events.getRootCommandId(event));
}
use of io.spine.server.event.EventFactory in project core-java by SpineEventEngine.
the class HandlerMethod method toEvents.
public static List<Event> toEvents(final Any producerId, @Nullable final Version version, final List<? extends Message> eventMessages, final MessageEnvelope origin) {
checkNotNull(producerId);
checkNotNull(eventMessages);
checkNotNull(origin);
final EventFactory eventFactory = EventFactory.on(origin, producerId);
return Lists.transform(eventMessages, new Function<Message, Event>() {
@Override
public Event apply(@Nullable Message eventMessage) {
checkNotNull(eventMessage);
final Event result = eventFactory.createEvent(eventMessage, version);
return result;
}
});
}
use of io.spine.server.event.EventFactory in project core-java by SpineEventEngine.
the class Given method validEvent.
static Event validEvent() {
final Command cmd = validCommand();
final PrjProjectCreated eventMessage = PrjProjectCreated.newBuilder().setProjectId(ProjectId.newBuilder().setId("12345AD0")).build();
final StringValue producerId = toMessage(Given.class.getSimpleName());
final EventFactory eventFactory = EventFactory.on(CommandEnvelope.of(cmd), Identifier.pack(producerId));
final Event event = eventFactory.createEvent(eventMessage, Tests.<Version>nullRef());
final Event result = event.toBuilder().setContext(event.getContext().toBuilder().setEnrichment(Enrichment.newBuilder().setDoNotEnrich(true)).build()).build();
return result;
}
Aggregations