Search in sources :

Example 6 with EventA

use of uk.gov.justice.services.core.aggregate.event.EventA in project microservice_framework by CJSCommonPlatform.

the class DefaultAggregateServiceTest method shouldThrowExceptionForUnregisteredEvent.

@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForUnregisteredEvent() {
    when(eventStream.getId()).thenReturn(STREAM_ID);
    JsonObject eventPayloadA = mock(JsonObject.class);
    EventA eventA = mock(EventA.class);
    when(jsonObjectToObjectConverter.convert(eventPayloadA, EventA.class)).thenReturn(eventA);
    when(eventStream.read()).thenReturn(Stream.of(envelopeFrom(metadataWithRandomUUID("eventA"), eventPayloadA)));
    aggregateService.get(eventStream, TestAggregate.class);
}
Also used : JsonObject(javax.json.JsonObject) EventA(uk.gov.justice.services.core.aggregate.event.EventA) Test(org.junit.Test)

Example 7 with EventA

use of uk.gov.justice.services.core.aggregate.event.EventA 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);
}
Also used : EventFoundEvent(uk.gov.justice.services.core.extension.EventFoundEvent) EventStream(uk.gov.justice.services.eventsourcing.source.core.EventStream) EnvelopeEventStream(uk.gov.justice.services.eventsourcing.source.core.EnvelopeEventStream) EventA(uk.gov.justice.services.core.aggregate.event.EventA) Test(org.junit.Test)

Aggregations

EventA (uk.gov.justice.services.core.aggregate.event.EventA)7 JsonObject (javax.json.JsonObject)6 Test (org.junit.Test)6 TestAggregate (uk.gov.justice.domain.aggregate.TestAggregate)3 EventB (uk.gov.justice.services.core.aggregate.event.EventB)2 EventFoundEvent (uk.gov.justice.services.core.extension.EventFoundEvent)2 EnvelopeEventStream (uk.gov.justice.services.eventsourcing.source.core.EnvelopeEventStream)1 EventStream (uk.gov.justice.services.eventsourcing.source.core.EventStream)1