use of io.spine.core.EventContext in project core-java by SpineEventEngine.
the class AggregateStorageShould method not_store_enrichment_for_EventContext.
@Test
public void not_store_enrichment_for_EventContext() {
final EventContext enrichedContext = EventContext.newBuilder().setEnrichment(withOneAttribute()).build();
final Event event = Event.newBuilder().setId(newEventId()).setContext(enrichedContext).setMessage(Any.getDefaultInstance()).build();
storage.writeEvent(id, event);
final EventContext loadedContext = storage.read(newReadRequest(id)).get().getEvent(0).getContext();
assertTrue(isDefault(loadedContext.getEnrichment()));
}
use of io.spine.core.EventContext in project core-java by SpineEventEngine.
the class AggregateStorageShould method not_store_enrichment_for_origin_of_RejectionContext_type.
@Test
public void not_store_enrichment_for_origin_of_RejectionContext_type() {
final RejectionContext origin = RejectionContext.newBuilder().setEnrichment(withOneAttribute()).build();
final EventContext context = EventContext.newBuilder().setRejectionContext(origin).build();
final Event event = Event.newBuilder().setId(newEventId()).setContext(context).setMessage(Any.getDefaultInstance()).build();
storage.writeEvent(id, event);
final RejectionContext loadedOrigin = storage.read(newReadRequest(id)).get().getEvent(0).getContext().getRejectionContext();
assertTrue(isDefault(loadedOrigin.getEnrichment()));
}
use of io.spine.core.EventContext in project core-java by SpineEventEngine.
the class AggregateStorageShould method not_store_enrichment_for_origin_of_EventContext_type.
@Test
public void not_store_enrichment_for_origin_of_EventContext_type() {
final EventContext origin = EventContext.newBuilder().setEnrichment(withOneAttribute()).build();
final EventContext context = EventContext.newBuilder().setEventContext(origin).build();
final Event event = Event.newBuilder().setId(newEventId()).setContext(context).setMessage(Any.getDefaultInstance()).build();
storage.writeEvent(id, event);
final EventContext loadedOrigin = storage.read(newReadRequest(id)).get().getEvent(0).getContext().getEventContext();
assertTrue(isDefault(loadedOrigin.getEnrichment()));
}
use of io.spine.core.EventContext in project core-java by SpineEventEngine.
the class EventStoreShould method fail_to_store_events_of_different_tenants_in_a_single_operation.
@Test(expected = IllegalArgumentException.class)
public void fail_to_store_events_of_different_tenants_in_a_single_operation() {
final TenantId firstTenantId = TenantId.newBuilder().setValue("abc").build();
final TenantId secondTenantId = TenantId.newBuilder().setValue("xyz").build();
final ActorContext firstTenantActor = ActorContext.newBuilder().setTenantId(firstTenantId).build();
final ActorContext secondTenantActor = ActorContext.newBuilder().setTenantId(secondTenantId).build();
final CommandContext firstTenantCommand = CommandContext.newBuilder().setActorContext(firstTenantActor).build();
final CommandContext secondTenantCommand = CommandContext.newBuilder().setActorContext(secondTenantActor).build();
final EventContext firstTenantContext = EventContext.newBuilder().setCommandContext(firstTenantCommand).build();
final EventContext secondTenantContext = EventContext.newBuilder().setCommandContext(secondTenantCommand).build();
final Event firstTenantEvent = Event.newBuilder().setContext(firstTenantContext).build();
final Event secondTenantEvent = Event.newBuilder().setContext(secondTenantContext).build();
final Collection<Event> event = ImmutableSet.of(firstTenantEvent, secondTenantEvent);
eventStore.appendAll(event);
}
use of io.spine.core.EventContext in project core-java by SpineEventEngine.
the class ProjectionEndpoint method onModified.
@Override
protected void onModified(P projection) {
final ProjectionRepository<I, P, ?> repository = repository();
repository.store(projection);
final EventContext eventContext = envelope().getEventContext();
final Timestamp eventTime = eventContext.getTimestamp();
repository.projectionStorage().writeLastHandledEventTime(eventTime);
repository.getStand().post(eventContext.getCommandContext().getActorContext().getTenantId(), projection);
}
Aggregations