Search in sources :

Example 26 with TestAggregate

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);
}
Also used : TestAggregate(uk.gov.justice.domain.aggregate.TestAggregate) Test(org.junit.Test)

Example 27 with TestAggregate

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);
}
Also used : TestAggregate(uk.gov.justice.domain.aggregate.TestAggregate) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Example 28 with TestAggregate

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);
}
Also used : TestAggregate(uk.gov.justice.domain.aggregate.TestAggregate) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Aggregations

TestAggregate (uk.gov.justice.domain.aggregate.TestAggregate)28 Test (org.junit.Test)27 UUID (java.util.UUID)8 UUID.randomUUID (java.util.UUID.randomUUID)8 JsonObject (javax.json.JsonObject)8 AggregateSnapshot (uk.gov.justice.domain.snapshot.AggregateSnapshot)8 MetadataBuilderFactory.metadataWithRandomUUID (uk.gov.justice.services.test.utils.core.messaging.MetadataBuilderFactory.metadataWithRandomUUID)8 EventA (uk.gov.justice.domain.event.EventA)7 VersionedAggregate (uk.gov.justice.domain.snapshot.VersionedAggregate)7 EventStream (uk.gov.justice.services.eventsourcing.source.core.EventStream)7 DefaultObjectInputStreamStrategy (uk.gov.justice.domain.snapshot.DefaultObjectInputStreamStrategy)5 EventA (uk.gov.justice.services.core.aggregate.event.EventA)5 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)5 EventB (uk.gov.justice.domain.event.EventB)4 SnapshotAwareEnvelopeEventStream (uk.gov.justice.services.eventsourcing.source.core.SnapshotAwareEnvelopeEventStream)4 EventB (uk.gov.justice.services.core.aggregate.event.EventB)3 EventFoundEvent (uk.gov.justice.services.core.extension.EventFoundEvent)3 EnvelopeEventStream (uk.gov.justice.services.eventsourcing.source.core.EnvelopeEventStream)3 NoSerializableTestAggregate (uk.gov.justice.domain.aggregate.NoSerializableTestAggregate)2 EventC (uk.gov.justice.domain.event.EventC)2