Search in sources :

Example 11 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldNotMatchAsJson.

@Test(expected = AssertionError.class)
public void shouldNotMatchAsJson() throws Exception {
    final Metadata metadata = defaultMetadataWithName(EVENT_NAME).build();
    assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().isJson(allOf(withJsonPath("$.id", equalTo(ID.toString())), withJsonPath("$.name", equalTo("does not match")))));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Example 12 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchMetadataByStreamId.

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

Example 13 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchWithNoSettings.

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

Example 14 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldFailIfSessionIdDoesNotMatch.

@Test(expected = AssertionError.class)
public void shouldFailIfSessionIdDoesNotMatch() throws Exception {
    final Metadata metadata = metadataWithRandomUUID(EVENT_NAME).withSessionId(SESSION_ID).build();
    assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().withSessionId("does not match"));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Example 15 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchAGivenMetadataWhereIdBecomesCausationAndDoesNotMatchName.

@Test
public void shouldMatchAGivenMetadataWhereIdBecomesCausationAndDoesNotMatchName() throws Exception {
    final Metadata testMetadata = defaultMetadataRandomIdWithName(EVENT_NAME).withCausation(ID, CAUSATION_ID).build();
    final Metadata expectedMetadata = defaultMetadataWithName(COMMAND_ACTION).build();
    assertThat(testMetadata, JsonEnvelopeMetadataMatcher.metadata().envelopedWith(expectedMetadata));
}
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