Search in sources :

Example 1 with EventStream

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) EventStream(uk.gov.justice.services.eventsourcing.repository.jdbc.eventstream.EventStream) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) Test(org.junit.Test)

Example 2 with EventStream

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();
}
Also used : ZonedDateTime(java.time.ZonedDateTime) EventStream(uk.gov.justice.services.eventsourcing.repository.jdbc.eventstream.EventStream) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) Test(org.junit.Test)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)2 UUID (java.util.UUID)2 UUID.randomUUID (java.util.UUID.randomUUID)2 Test (org.junit.Test)2 EventStream (uk.gov.justice.services.eventsourcing.repository.jdbc.eventstream.EventStream)2