use of uk.gov.justice.services.eventsourcing.source.core.EventStream in project microservice_framework by CJSCommonPlatform.
the class DefaultAggregateServiceIT method shouldThrowExceptionForUnregisteredEvent.
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForUnregisteredEvent() throws EventStreamException {
final EventStream eventStream = eventSource.getStreamById(STREAM_ID);
eventStream.append(Stream.of(envelopeFrom("context.eventA")));
aggregateService.get(eventStream, TestAggregate.class);
}
use of uk.gov.justice.services.eventsourcing.source.core.EventStream in project microservice_framework by CJSCommonPlatform.
the class DefaultAggregateServiceIT method shouldThrowExceptionForNonInstantiatableEvent.
@Test(expected = RuntimeException.class)
public void shouldThrowExceptionForNonInstantiatableEvent() throws EventStreamException {
final EventStream eventStream = eventSource.getStreamById(STREAM_ID);
aggregateService.register(new EventFoundEvent(EventA.class, "eventA"));
aggregateService.get(eventStream, PrivateAggregate.class);
}
use of uk.gov.justice.services.eventsourcing.source.core.EventStream in project microservice_framework by CJSCommonPlatform.
the class RecipeCommandHandler method removeRecipe.
@Handles("example.command.remove-recipe")
public void removeRecipe(final JsonEnvelope command) throws EventStreamException {
LOGGER.trace("=============> Inside remove-recipe Command Handler. RecipeId: " + command.payloadAsJsonObject().getString(FIELD_RECIPE_ID));
final UUID recipeId = getUUID(command.payloadAsJsonObject(), FIELD_RECIPE_ID).get();
final EventStream eventStream = eventSource.getStreamById(recipeId);
final Recipe recipe = aggregateService.get(eventStream, Recipe.class);
eventStream.append(recipe.removeRecipe().map(toEnvelopeWithMetadataFrom(command)));
}
Aggregations