Search in sources :

Example 41 with Metadata

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

the class DefaultJsonMetadataTest method shouldTestEqualsAndHashCode.

@SuppressWarnings({ "squid:MethodCyclomaticComplexity", "squid:S1067", "squid:S00122" })
@Test
public void shouldTestEqualsAndHashCode() {
    final Metadata item1 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID_USER_ID, UUID_SESSION_ID, UUID_STREAM_ID, MESSAGE_NAME, STREAM_VERSION);
    final Metadata item2 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID_USER_ID, UUID_SESSION_ID, UUID_STREAM_ID, MESSAGE_NAME, STREAM_VERSION);
    final Metadata item3 = metadata(UUID.randomUUID().toString(), UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID_USER_ID, UUID_SESSION_ID, UUID_STREAM_ID, MESSAGE_NAME, STREAM_VERSION);
    final Metadata item4 = metadata(UUID_ID, UUID.randomUUID().toString(), UUID_CAUSATION, UUID_USER_ID, UUID_SESSION_ID, UUID_STREAM_ID, MESSAGE_NAME, STREAM_VERSION);
    final Metadata item5 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID.randomUUID().toString(), UUID_USER_ID, UUID_SESSION_ID, UUID_STREAM_ID, MESSAGE_NAME, STREAM_VERSION);
    final Metadata item6 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID.randomUUID().toString(), UUID_SESSION_ID, UUID_STREAM_ID, MESSAGE_NAME, STREAM_VERSION);
    final Metadata item7 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID_USER_ID, UUID.randomUUID().toString(), UUID_STREAM_ID, MESSAGE_NAME, STREAM_VERSION);
    final Metadata item8 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID_USER_ID, UUID_SESSION_ID, UUID.randomUUID().toString(), MESSAGE_NAME, STREAM_VERSION);
    final Metadata item9 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID_USER_ID, UUID_SESSION_ID, UUID_STREAM_ID, "dummy name", STREAM_VERSION);
    final Metadata item10 = metadata(UUID_ID, UUID_CLIENT_CORRELATION, UUID_CAUSATION, UUID_USER_ID, UUID_SESSION_ID, UUID_STREAM_ID, MESSAGE_NAME, 0L);
    new EqualsTester().addEqualityGroup(item1, item2).addEqualityGroup(item3).addEqualityGroup(item4).addEqualityGroup(item5).addEqualityGroup(item6).addEqualityGroup(item7).addEqualityGroup(item8).addEqualityGroup(item9).addEqualityGroup(item10).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Example 42 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchMetadataBySessionId.

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

Example 43 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldFailIfNameDoesNotMatch.

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

Example 44 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldMatchAGivenMetadata.

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

Example 45 with Metadata

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

the class JsonEnvelopeMetadataMatcherTest method shouldFailIfUserIdDoesNotMatch.

@Test(expected = AssertionError.class)
public void shouldFailIfUserIdDoesNotMatch() throws Exception {
    final Metadata metadata = metadataWithRandomUUID(EVENT_NAME).withUserId(USER_ID).build();
    assertThat(metadata, JsonEnvelopeMetadataMatcher.metadata().withUserId("does not match"));
}
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