use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class JsonEnvelopeMetadataMatcherTest method shouldMatchMetadataByClientCorrelationId.
@Test
public void shouldMatchMetadataByClientCorrelationId() throws Exception {
final Metadata metadata = metadataWithRandomUUID(EVENT_NAME).withClientCorrelationId(CLIENT_CORRELATION_ID).build();
assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().withClientCorrelationId(CLIENT_CORRELATION_ID));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class JsonEnvelopeMetadataMatcherTest method shouldFailIfVersionDoesNotMatch.
@Test(expected = AssertionError.class)
public void shouldFailIfVersionDoesNotMatch() throws Exception {
final Metadata metadata = metadataWithRandomUUID(EVENT_NAME).withVersion(1L).build();
assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().withVersion(2L));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class EventsPageIT method storeEvents.
private void storeEvents(final int eventNumber) throws InvalidPositionException {
for (int i = 1; i <= eventNumber; i++) {
final UUID id = randomUUID();
final Metadata metadata = JsonEnvelope.metadataBuilder().withId(id).withStreamId(STREAM_ID).withName("name").createdAt(now()).withVersion(i).build();
final Event event = new Event(randomUUID(), STREAM_ID, valueOf(i), "Test Name" + i, metadata.asJsonObject().toString(), createObjectBuilder().add("field" + i, "value" + i).build().toString(), new UtcClock().now());
eventsRepository.insert(event);
}
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class EnvelopeInspectorTest method shouldGetTheActionNameOfAnEnvelope.
@Test
public void shouldGetTheActionNameOfAnEnvelope() throws Exception {
final String actionName = "example.an-action";
final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class);
final Metadata metadata = mock(Metadata.class);
when(jsonEnvelope.metadata()).thenReturn(metadata);
when(metadata.name()).thenReturn(actionName);
assertThat(envelopeInspector.getActionNameFor(jsonEnvelope), is(actionName));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultEnveloperProviderTest method shouldEnvelopWithDefaultEnvelope.
@Test
public void shouldEnvelopWithDefaultEnvelope() {
final Metadata metadata = createMetadata();
final TestPojo payload = new TestPojo(TEST_EVENT_NAME);
final Envelope<TestPojo> envelope = envelopeFrom(metadata, payload);
final Envelope<TestPojo> resultEnvelope = new DefaultEnveloperProvider().envelop(payload).withName(TEST_EVENT_NAME).withMetadataFrom(envelope);
assertThat(resultEnvelope, instanceOf(DefaultEnvelope.class));
assertThat(resultEnvelope.metadata().name(), is(metadata.name()));
assertThat(resultEnvelope.payload(), is(payload));
}
Aggregations