use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonEnvelopeProviderTest method shouldProvideDefaultJsonEnvelopeFromMetadataBuilderAndJsonObjectBuilder.
@Test
public void shouldProvideDefaultJsonEnvelopeFromMetadataBuilderAndJsonObjectBuilder() throws Exception {
final UUID id = randomUUID();
final String name = "name";
final MetadataBuilder metadataBuilder = metadataBuilder().withId(id).withName(name);
final JsonObjectBuilder jsonObjectBuilder = createObjectBuilder().add("test", "value");
final JsonEnvelope envelope = new DefaultJsonEnvelopeProvider().envelopeFrom(metadataBuilder, jsonObjectBuilder);
assertThat(envelope, instanceOf(DefaultJsonEnvelope.class));
final Metadata metadata = envelope.metadata();
assertThat(metadata.id(), is(id));
assertThat(metadata.name(), is(name));
with(envelope.payload().toString()).assertEquals("test", "value");
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonEnvelopeProviderTest method shouldProvideJsonObjectMetadataBuilderFromMetadata.
@Test
public void shouldProvideJsonObjectMetadataBuilderFromMetadata() throws Exception {
final UUID id = randomUUID();
final String name = "name";
final Metadata metadata = metadataBuilder().withId(id).withName(name).build();
final MetadataBuilder metadataBuilder = new DefaultJsonEnvelopeProvider().metadataFrom(metadata);
assertThat(metadataBuilder, instanceOf(DefaultJsonMetadata.Builder.class));
final Metadata resultMetadata = metadataBuilder.build();
assertThat(resultMetadata.id(), is(id));
assertThat(resultMetadata.name(), is(name));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonEnvelopeProviderTest method shouldProvideDefaultJsonEnvelopeFromMetadataAndJsonValue.
@Test
public void shouldProvideDefaultJsonEnvelopeFromMetadataAndJsonValue() throws Exception {
final Metadata metadata = mock(Metadata.class);
final JsonValue payload = mock(JsonValue.class);
final JsonEnvelope envelope = new DefaultJsonEnvelopeProvider().envelopeFrom(metadata, payload);
assertThat(envelope, instanceOf(DefaultJsonEnvelope.class));
assertThat(envelope.metadata(), is(metadata));
assertThat(envelope.payload(), is(payload));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonMetadataBuilderTest method shouldBuildMetadataWithCausation.
@Test
public void shouldBuildMetadataWithCausation() throws Exception {
final UUID id1 = randomUUID();
final UUID id2 = randomUUID();
final Metadata metadata = metadataWithDefaults().withCausation(id1, id2).build();
assertThat(metadata.causation(), hasItems(id1, id2));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonMetadataBuilderTest method shouldBuildMetadataWithClientCorrelationId.
@Test
public void shouldBuildMetadataWithClientCorrelationId() throws Exception {
final String correlationId = "d51597dc-2526-4c71-bd08-5031c79f11e1";
final Metadata metadata = metadataWithDefaults().withClientCorrelationId(correlationId).build();
assertThat(metadata.clientCorrelationId().get(), is(correlationId));
}
Aggregations