use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonEnvelopeProviderTest method shouldProvideJsonObjectMetadataBuilderFromJsonObject.
@Test
public void shouldProvideJsonObjectMetadataBuilderFromJsonObject() 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.asJsonObject());
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 DefaultJsonMetadataBuilderTest method shouldBuildFromMetadataAndOverwriteFields.
@Test
public void shouldBuildFromMetadataAndOverwriteFields() throws Exception {
final UUID id = randomUUID();
final UUID streamId = randomUUID();
final UUID causationId1 = randomUUID();
final UUID causationId2 = randomUUID();
final String name = "some.name";
final Metadata originalMetadata = metadataBuilder().withId(id).withName(name).withUserId("usrIdAAAA").withStreamId(streamId).withCausation(causationId1, causationId2).build();
final Metadata metadata = metadataBuilderFrom(originalMetadata).withUserId("usrIdBBBB").withVersion(4L).build();
assertThat(metadata.version(), contains(4L));
assertThat(metadata.userId(), contains("usrIdBBBB"));
assertThat(metadata.id(), is(id));
assertThat(metadata.name(), is(name));
assertThat(metadata.streamId(), contains(streamId));
assertThat(metadata.causation(), hasItems(causationId1, causationId2));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonMetadataBuilderTest method shouldBuildMetadataWithSessionId.
@Test
public void shouldBuildMetadataWithSessionId() {
final String sessionId = "b51597dc-2526-4c71-bd08-5031c79f11e3";
final Metadata metadata = metadataWithDefaults().withSessionId(sessionId).build();
assertThat(metadata.sessionId().get(), is(sessionId));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonMetadataBuilderTest method shouldBuildMetadataWithStreamIdAndVersion.
@Test
public void shouldBuildMetadataWithStreamIdAndVersion() {
final UUID streamId = randomUUID();
final Long version = 1234567l;
final Metadata metadata = metadataWithDefaults().withStreamId(streamId).withVersion(version).build();
assertThat(metadata.streamId().get(), is(streamId));
assertThat(metadata.version().get(), is(version));
}
use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.
the class DefaultJsonMetadataBuilderTest method shouldBuildMetadataWithMandatoryElements.
@Test
public void shouldBuildMetadataWithMandatoryElements() {
final UUID id = randomUUID();
final String name = "some.name";
final Metadata metadata = metadataBuilder().withId(id).withName(name).build();
assertThat(metadata.id(), is(id));
assertThat(metadata.name(), is(name));
}
Aggregations