use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class EventBufferAndFilterChainIT method shouldAllowUnsupportedEventThroughBufferAndFilterOutAfterwards.
// Uncomment below to test when deplpoyed to the vagrant vm
/*
@Configuration
public Properties postgresqlConfiguration() {
return OpenEjbConfigurationBuilder.createOpenEjbConfigurationBuilder()
.addInitialContext()
.addPostgresqlViewStore()
.build();
}
*/
@Test
public void shouldAllowUnsupportedEventThroughBufferAndFilterOutAfterwards() {
final UUID metadataId1 = randomUUID();
final UUID metadataId2 = randomUUID();
final UUID metadataId3 = randomUUID();
final UUID streamId = randomUUID();
final JsonEnvelope jsonEnvelope_1 = envelope().with(metadataOf(metadataId2, EVENT_UNSUPPORTED_DEF).withStreamId(streamId).withVersion(2L)).build();
final JsonEnvelope jsonEnvelope_2 = envelope().with(metadataOf(metadataId3, EVENT_SUPPORTED_ABC).withStreamId(streamId).withVersion(3L)).build();
final JsonEnvelope jsonEnvelope_3 = envelope().with(metadataOf(metadataId1, EVENT_SUPPORTED_ABC).withStreamId(streamId).withVersion(1L)).build();
interceptorChainProcessor.process(interceptorContextWithInput(jsonEnvelope_1));
interceptorChainProcessor.process(interceptorContextWithInput(jsonEnvelope_2));
interceptorChainProcessor.process(interceptorContextWithInput(jsonEnvelope_3));
assertThat(abcEventHandler.recordedEnvelopes(), not(empty()));
assertThat(abcEventHandler.recordedEnvelopes().get(0).metadata().id(), equalTo(metadataId1));
assertThat(abcEventHandler.recordedEnvelopes().get(0).metadata().version(), contains(1L));
assertThat(abcEventHandler.recordedEnvelopes().get(1).metadata().id(), equalTo(metadataId3));
assertThat(abcEventHandler.recordedEnvelopes().get(1).metadata().version(), contains(3L));
assertThat(defEventHandler.recordedEnvelopes(), empty());
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class JsonSchemaValidationMatcherTest method shouldFailToValidateJsonEnvelopeAgainstSchemaForActionNameOfEnvelope.
@Test(expected = AssertionError.class)
public void shouldFailToValidateJsonEnvelopeAgainstSchemaForActionNameOfEnvelope() throws Exception {
final JsonEnvelope jsonEnvelope = envelope().with(metadataWithRandomUUID("event.action")).withPayloadOf("id", "someId").build();
assertThat(jsonEnvelope, JsonSchemaValidationMatcher.isValidJsonEnvelopeForSchema());
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class JsonSchemaValidationMatcherTest method shouldFallbackToRamlPathIfNotFoundInJsonPath.
@Test
public void shouldFallbackToRamlPathIfNotFoundInJsonPath() throws Exception {
final JsonEnvelope jsonEnvelope = envelope().with(metadataWithRandomUUID("fallback.action")).withPayloadOf("id", "fallback").build();
assertThat(jsonEnvelope, JsonSchemaValidationMatcher.isValidJsonEnvelopeForSchema());
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class SnapshotAwareAggregateServiceIT method createEventStreamAndApply.
private <T extends Aggregate> void createEventStreamAndApply(final UUID streamId, final long count, final String eventName, final Class<T> aggregateClass) throws EventStreamException {
final EventStream eventStream = eventSource.getStreamById(streamId);
final T aggregate = aggregateService.get(eventStream, aggregateClass);
final List<JsonEnvelope> envelopes = new LinkedList<>();
for (int i = 1; i <= count; i++) {
final JsonEnvelope envelope = envelope().with(metadataWithRandomUUID(eventName).createdAt(clock.now()).withStreamId(streamId)).withPayloadOf("value", "name").build();
aggregate.apply(new EventA(String.valueOf(i)));
envelopes.add(envelope);
}
eventStream.append(envelopes.stream());
}
use of uk.gov.justice.services.messaging.JsonEnvelope in project microservice_framework by CJSCommonPlatform.
the class SnapshotAwareAggregateServiceIT method createEventAndApply.
private Stream<JsonEnvelope> createEventAndApply(final UUID streamId, final long count, final TestAggregate aggregate) {
final List<JsonEnvelope> envelopes = new LinkedList<>();
for (int i = 1; i <= count; i++) {
final JsonEnvelope envelope = envelope().with(metadataWithRandomUUID("context.eventA").createdAt(clock.now()).withStreamId(streamId)).withPayloadOf("value", "name").build();
aggregate.addEvent(envelope);
envelopes.add(envelope);
}
return envelopes.stream();
}
Aggregations