use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class RestEnvelopeBuilderTest method shouldMergeHeaderWithPayloadMetadataWithMultipleCausation.
@Test
public void shouldMergeHeaderWithPayloadMetadataWithMultipleCausation() throws Exception {
final List<UUID> uuids = asList(randomUUID(), randomUUID());
final String uuidsCsv = String.join(",", uuids.stream().map(UUID::toString).collect(toList()));
final Optional<JsonObject> initialPayload = Optional.of(createObjectBuilder().add(METADATA, createObjectBuilder().add(ID, PAYLOAD_METADATA_ID.toString()).add(NAME, PAYLOAD_NAME).add(STREAM, createObjectBuilder().add(STREAM_ID, UUID_STREAM_ID.toString()).add(VERSION, VERSION_VALUE))).add("test", "value").build());
final JsonEnvelope envelope = builderWithDefaultAction().withInitialPayload(initialPayload).withHeaders(httpHeadersOf(ImmutableMap.of(CLIENT_CORRELATION_ID, UUID_CLIENT_CORRELATION_ID.toString(), HeaderConstants.USER_ID, UUID_USER_ID.toString(), HeaderConstants.SESSION_ID, UUID_SESSION_ID.toString(), HeaderConstants.CAUSATION, uuidsCsv))).build();
final Metadata metadata = envelope.metadata();
assertThat(metadata.id(), is(PAYLOAD_METADATA_ID));
assertThat(metadata.name(), is(PAYLOAD_NAME));
assertThat(metadata.sessionId(), is(Optional.of(UUID_SESSION_ID.toString())));
assertThat(metadata.userId(), is(Optional.of(UUID_USER_ID.toString())));
assertThat(metadata.clientCorrelationId(), is(Optional.of(UUID_CLIENT_CORRELATION_ID.toString())));
assertThat(metadata.streamId(), is(Optional.of(UUID_STREAM_ID)));
assertThat(metadata.version(), is(Optional.of(VERSION_VALUE)));
assertThat(metadata.causation(), is(uuids));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class RestEnvelopeBuilderTest method shouldMergeHeaderWithPayloadMetadata.
@Test
public void shouldMergeHeaderWithPayloadMetadata() throws Exception {
final Optional<JsonObject> initialPayload = Optional.of(createObjectBuilder().add(METADATA, createObjectBuilder().add(ID, PAYLOAD_METADATA_ID.toString()).add(NAME, PAYLOAD_NAME).add(STREAM, createObjectBuilder().add(STREAM_ID, UUID_STREAM_ID.toString()).add(VERSION, VERSION_VALUE))).add("test", "value").build());
final JsonEnvelope envelope = builderWithDefaultAction().withInitialPayload(initialPayload).withHeaders(httpHeadersOf(ImmutableMap.of(CLIENT_CORRELATION_ID, UUID_CLIENT_CORRELATION_ID.toString(), HeaderConstants.USER_ID, UUID_USER_ID.toString(), HeaderConstants.SESSION_ID, UUID_SESSION_ID.toString(), HeaderConstants.CAUSATION, SINGLE_CAUSATION_ID.toString()))).build();
final Metadata metadata = envelope.metadata();
assertThat(metadata.id(), is(PAYLOAD_METADATA_ID));
assertThat(metadata.name(), is(PAYLOAD_NAME));
assertThat(metadata.sessionId(), is(Optional.of(UUID_SESSION_ID.toString())));
assertThat(metadata.userId(), is(Optional.of(UUID_USER_ID.toString())));
assertThat(metadata.clientCorrelationId(), is(Optional.of(UUID_CLIENT_CORRELATION_ID.toString())));
assertThat(metadata.streamId(), is(Optional.of(UUID_STREAM_ID)));
assertThat(metadata.version(), is(Optional.of(VERSION_VALUE)));
assertThat(metadata.causation().get(0), is(SINGLE_CAUSATION_ID));
}
Aggregations