Search in sources :

Example 6 with Metadata

use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.

the class DefaultJsonMetadataBuilderTest method shouldBuildMetadataWithUserId.

@Test
public void shouldBuildMetadataWithUserId() {
    final String userId = "a51597dc-2526-4c71-bd08-5031c79f11e3";
    final Metadata metadata = metadataWithDefaults().withUserId(userId).build();
    assertThat(metadata.userId().get(), is(userId));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Example 7 with Metadata

use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.

the class DefaultJsonMetadataBuilderTest method shouldBuildMetadataWithStreamId.

@Test
public void shouldBuildMetadataWithStreamId() {
    final UUID streamId = randomUUID();
    final Metadata metadata = metadataWithDefaults().withStreamId(streamId).build();
    assertThat(metadata.streamId().get(), is(streamId));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) UUID.randomUUID(java.util.UUID.randomUUID) UUID(java.util.UUID) Test(org.junit.Test)

Example 8 with Metadata

use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.

the class JsonEnvelopeBuilderTest method shouldBuildJsonEnvelopeFromMetadataAndJsonValue.

@Test
public void shouldBuildJsonEnvelopeFromMetadataAndJsonValue() throws Exception {
    final Metadata metadata = mock(Metadata.class);
    final JsonValue payload = mock(JsonValue.class);
    final JsonEnvelope envelope = JsonEnvelopeBuilder.envelopeFrom(metadata, payload);
    assertThat(envelope.metadata(), is(metadata));
    assertThat(envelope.payload(), is(payload));
}
Also used : JsonObjectMetadata(uk.gov.justice.services.messaging.JsonObjectMetadata) Metadata(uk.gov.justice.services.messaging.Metadata) JsonValue(javax.json.JsonValue) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Example 9 with Metadata

use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.

the class JsonEnvelopeMetadataMatcherTest method shouldMatchAGivenMetadataWhereEnvelopedFromJsonEnvelope.

@Test
public void shouldMatchAGivenMetadataWhereEnvelopedFromJsonEnvelope() throws Exception {
    final Metadata testMetadata = defaultMetadataRandomIdWithName(EVENT_NAME).withCausation(ID, CAUSATION_ID).build();
    final JsonEnvelope jsonEnvelope = envelope().with(defaultMetadataWithName(COMMAND_ACTION)).withPayloadOf("Test", "value").build();
    assertThat(testMetadata, JsonEnvelopeMetadataMatcher.withMetadataEnvelopedFrom(jsonEnvelope));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Example 10 with Metadata

use of uk.gov.justice.services.messaging.Metadata in project microservice_framework by CJSCommonPlatform.

the class JsonEnvelopeMetadataMatcherTest method shouldFailIfStreamIdDoesNotMatch.

@Test(expected = AssertionError.class)
public void shouldFailIfStreamIdDoesNotMatch() throws Exception {
    final Metadata metadata = metadataWithRandomUUID(EVENT_NAME).withStreamId(randomUUID()).build();
    assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().withStreamId(randomUUID()));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Aggregations

Metadata (uk.gov.justice.services.messaging.Metadata)67 Test (org.junit.Test)58 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)19 UUID (java.util.UUID)17 UUID.randomUUID (java.util.UUID.randomUUID)11 JsonObject (javax.json.JsonObject)10 JsonObjects.getJsonObject (uk.gov.justice.services.messaging.JsonObjects.getJsonObject)8 MetadataBuilder (uk.gov.justice.services.messaging.MetadataBuilder)6 JsonObjectBuilder (javax.json.JsonObjectBuilder)5 JsonValue (javax.json.JsonValue)3 JsonObjects.getString (uk.gov.justice.services.messaging.JsonObjects.getString)3 Json.createObjectBuilder (javax.json.Json.createObjectBuilder)2 HttpHeaders (javax.ws.rs.core.HttpHeaders)2 UtcClock (uk.gov.justice.services.common.util.UtcClock)2 Interceptor (uk.gov.justice.services.core.interceptor.Interceptor)2 InterceptorChain (uk.gov.justice.services.core.interceptor.InterceptorChain)2 InterceptorContext (uk.gov.justice.services.core.interceptor.InterceptorContext)2 JsonEnvelope.metadataBuilder (uk.gov.justice.services.messaging.JsonEnvelope.metadataBuilder)2 EqualsTester (com.google.common.testing.EqualsTester)1 String.format (java.lang.String.format)1