use of uk.gov.justice.domain.aggregate.TestAggregate in project microservice_framework by CJSCommonPlatform.
the class SnapshotAwareEnvelopeEventStreamTest method shouldNotCreateSnapshotWhenAppendingWithNonConsecutiveTolerance.
@Test
public void shouldNotCreateSnapshotWhenAppendingWithNonConsecutiveTolerance() throws Exception {
eventStream.registerAggregates(TestAggregate.class, new TestAggregate());
eventStream.append(Stream.of(envelope().build()), Tolerance.NON_CONSECUTIVE);
verifyZeroInteractions(snapshotService);
}
use of uk.gov.justice.domain.aggregate.TestAggregate in project microservice_framework by CJSCommonPlatform.
the class SnapshotAwareEnvelopeEventStreamTest method shouldAttemptSnapshotCreationOnAppendingEventsFrom.
@Test
public void shouldAttemptSnapshotCreationOnAppendingEventsFrom() throws Exception {
final TestAggregate aggregate = new TestAggregate();
eventStream.registerAggregates(TestAggregate.class, aggregate);
final long streamVersionToAppendAfter = 16L;
final long streamVersionAfterAppending = 17L;
final Stream<JsonEnvelope> streamOfEvents = Stream.of(envelope().build());
when(eventStreamManager.appendAfter(STREAM_ID, streamOfEvents, streamVersionToAppendAfter)).thenReturn(streamVersionAfterAppending);
eventStream.appendAfter(streamOfEvents, streamVersionToAppendAfter);
verify(snapshotService).attemptAggregateStore(STREAM_ID, streamVersionAfterAppending, aggregate);
}
use of uk.gov.justice.domain.aggregate.TestAggregate in project microservice_framework by CJSCommonPlatform.
the class SnapshotAwareEnvelopeEventStreamTest method shouldAttemptSnapshotCreationWhenAppendingWithConsecutiveTolerance.
@Test
public void shouldAttemptSnapshotCreationWhenAppendingWithConsecutiveTolerance() throws Exception {
final TestAggregate aggregate = new TestAggregate();
eventStream.registerAggregates(TestAggregate.class, aggregate);
final long streamVersionAfterAppending = 16L;
final Stream<JsonEnvelope> streamOfEvents = Stream.of(envelope().build());
when(eventStreamManager.append(STREAM_ID, streamOfEvents)).thenReturn(streamVersionAfterAppending);
eventStream.append(streamOfEvents, Tolerance.CONSECUTIVE);
verify(snapshotService).attemptAggregateStore(STREAM_ID, streamVersionAfterAppending, aggregate);
}
Aggregations