use of uk.gov.justice.services.eventsourcing.repository.jdbc.eventstream.EventStream in project microservice_framework by CJSCommonPlatform.
the class DefaultEventRepositoryTest method shouldGetEventStreamByPosition.
@Test
public void shouldGetEventStreamByPosition() {
long position = 3l;
final UUID streamId = randomUUID();
final boolean active = true;
final ZonedDateTime createdAt = now();
final EventStream eventStream1 = new EventStream(streamId, position, true, createdAt);
final Stream<EventStream> eventStreams = Stream.of(eventStream1);
when(eventStreamJdbcRepository.findEventStreamWithPositionFrom(position)).thenReturn(eventStreams);
final Stream<EventStreamMetadata> streamOfEnvelopes = defaultEventRepository.getEventStreamsFromPosition(position);
final List<EventStreamMetadata> eventStreamMetadataList = streamOfEnvelopes.collect(toList());
assertThat(eventStreamMetadataList.size(), is(1));
assertThat(streamOfEnvelopes, not(nullValue()));
assertThat(eventStreamMetadataList.get(0).getStreamId(), equalTo(streamId));
assertThat(eventStreamMetadataList.get(0).getPosition(), equalTo(position));
assertThat(eventStreamMetadataList.get(0).isActive(), equalTo(active));
assertThat(eventStreamMetadataList.get(0).getCreatedAt(), equalTo(createdAt));
verify(eventStreamJdbcRepository).findEventStreamWithPositionFrom(position);
}
use of uk.gov.justice.services.eventsourcing.repository.jdbc.eventstream.EventStream in project microservice_framework by CJSCommonPlatform.
the class DefaultEventRepositoryTest method shouldGetAllEventStreams.
@Test
public void shouldGetAllEventStreams() {
long position = 3l;
final UUID streamId = randomUUID();
final boolean active = true;
final ZonedDateTime createdAt = now();
final EventStream eventStream1 = new EventStream(streamId, position, true, createdAt);
final Stream<EventStream> eventStreams = Stream.of(eventStream1);
when(eventStreamJdbcRepository.findAll()).thenReturn(eventStreams);
final Stream<EventStreamMetadata> streamOfEnvelopes = defaultEventRepository.getStreams();
final List<EventStreamMetadata> eventStreamMetadataList = streamOfEnvelopes.collect(toList());
assertThat(eventStreamMetadataList.size(), is(1));
assertThat(streamOfEnvelopes, not(nullValue()));
assertThat(eventStreamMetadataList.get(0).getStreamId(), equalTo(streamId));
assertThat(eventStreamMetadataList.get(0).getPosition(), equalTo(position));
assertThat(eventStreamMetadataList.get(0).isActive(), equalTo(active));
assertThat(eventStreamMetadataList.get(0).getCreatedAt(), equalTo(createdAt));
verify(eventStreamJdbcRepository).findAll();
}
Aggregations