Search in sources :

Example 51 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchAsJson.

@Test
public void shouldMatchAsJson() throws Exception {
    final Metadata metadata = defaultMetadataWithName(EVENT_NAME).build();
    assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().isJson(allOf(withJsonPath("$.id", equalTo(ID.toString())), withJsonPath("$.name", equalTo(EVENT_NAME)), withJsonPath("$.context.user", equalTo(USER_ID)))));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Example 52 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchMetadataByName.

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

Example 53 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldFailIfCausationIdDoesNotMatch.

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

Example 54 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldFailIfClientCorrelationIdDoesNotMatch.

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

Example 55 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchMetadataAll.

@Test
public void shouldMatchMetadataAll() throws Exception {
    final Metadata metadata = defaultMetadataWithName(EVENT_NAME).build();
    assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().withId(ID).withName(EVENT_NAME).withCausationIds(CAUSATION_ID).withUserId(USER_ID).withSessionId(SESSION_ID).withStreamId(STREAM_ID).withVersion(VERSION).withClientCorrelationId(CLIENT_CORRELATION_ID));
}
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