use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class EventStreamMockHelperTest method shouldVerifyAppendCallAndReturnStreamOfJsonEnvelopes.
@Test
public void shouldVerifyAppendCallAndReturnStreamOfJsonEnvelopes() throws Exception {
final EventStream eventStream = mock(EventStream.class);
final JsonEnvelope jsonEnvelope_1 = mock(JsonEnvelope.class);
final JsonEnvelope jsonEnvelope_2 = mock(JsonEnvelope.class);
eventStream.append(Stream.of(jsonEnvelope_1, jsonEnvelope_2));
final Stream<JsonEnvelope> jsonEnvelopeStream = EventStreamMockHelper.verifyAppendAndGetArgumentFrom(eventStream);
final List<JsonEnvelope> jsonEnvelopes = jsonEnvelopeStream.collect(toList());
assertThat(jsonEnvelopes, contains(jsonEnvelope_1, jsonEnvelope_2));
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class EventStreamMatcherTest method shouldMatchJsonEnvelopeStreamAppendedAfterVersionOfEventStream.
@Test
public void shouldMatchJsonEnvelopeStreamAppendedAfterVersionOfEventStream() throws Exception {
final JsonEnvelope event_1 = jsonEnvelopeWith(ID_1, NAME_1);
final JsonEnvelope event_2 = jsonEnvelopeWith(ID_2, NAME_2);
eventStream.appendAfter(Stream.of(event_1, event_2), VERSION);
assertThat(eventStream, EventStreamMatcher.eventStreamAppendedAfter(VERSION).with(streamContaining(jsonEnvelope(metadata().withName("event.action"), payloadIsJson(allOf(withJsonPath("$.someId", equalTo(ID_1.toString())), withJsonPath("$.name", equalTo(NAME_1))))), jsonEnvelope(metadata().withName("event.action"), payloadIsJson(allOf(withJsonPath("$.someId", equalTo(ID_2.toString())), withJsonPath("$.name", equalTo(NAME_2))))))));
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class EventStreamMatcherTest method shouldNotMatchJsonEnvelopeStreamAppendedAfterVersionOfEventStreamIfJsonEnvelopeIsMissing.
@Test(expected = AssertionError.class)
public void shouldNotMatchJsonEnvelopeStreamAppendedAfterVersionOfEventStreamIfJsonEnvelopeIsMissing() throws Exception {
final JsonEnvelope event_1 = jsonEnvelopeWith(ID_1, NAME_1);
final JsonEnvelope event_2 = jsonEnvelopeWith(ID_2, NAME_2);
eventStream.appendAfter(Stream.of(event_1, event_2), VERSION);
assertThat(eventStream, EventStreamMatcher.eventStreamAppendedAfter(VERSION).with(streamContaining(jsonEnvelope(metadata().withName("event.action"), payloadIsJson(allOf(withJsonPath("$.someId", equalTo(ID_1.toString())), withJsonPath("$.name", equalTo(NAME_1))))))));
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class EventStreamMatcherTest method shouldNotMatchANonEmptyStream.
@Test(expected = AssertionError.class)
public void shouldNotMatchANonEmptyStream() throws Exception {
final JsonEnvelope event_1 = jsonEnvelopeWith(ID_1, NAME_1);
eventStream.append(Stream.of(event_1));
assertThat(eventStream, EventStreamMatcher.eventStreamWithEmptyStream());
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class EventStreamMatcherTest method shouldNotMatchJsonEnvelopesStreamAppendedToEventStreamIfJsonEnvelopeIsMissing.
@Test(expected = AssertionError.class)
public void shouldNotMatchJsonEnvelopesStreamAppendedToEventStreamIfJsonEnvelopeIsMissing() throws Exception {
final JsonEnvelope event_1 = jsonEnvelopeWith(ID_1, NAME_1);
final JsonEnvelope event_2 = jsonEnvelopeWith(ID_2, NAME_2);
eventStream.append(Stream.of(event_1, event_2));
assertThat(eventStream, EventStreamMatcher.eventStreamAppendedWith(streamContaining(jsonEnvelope(metadata().withName("event.action"), payloadIsJson(allOf(withJsonPath("$.someId", equalTo(ID_1.toString())), withJsonPath("$.name", equalTo(NAME_1))))))));
}
Aggregations