Search in sources :

Example 56 with Metadata

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

the class MetadataBuilderFactoryTest method shouldProvideMetadataBuilderWithUuidAndName.

@Test
public void shouldProvideMetadataBuilderWithUuidAndName() throws Exception {
    final UUID id = UUID.randomUUID();
    final String name = "name";
    final Metadata metadata = MetadataBuilderFactory.metadataOf(id, name).build();
    assertThat(metadata.id(), is(id));
    assertThat(metadata.name(), is(name));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) UUID(java.util.UUID) Test(org.junit.Test)

Example 57 with Metadata

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

the class MetadataBuilderFactoryTest method shouldProvideMetadataBuilderWithUuidAsStringAndName.

@Test
public void shouldProvideMetadataBuilderWithUuidAsStringAndName() throws Exception {
    final UUID id = UUID.randomUUID();
    final String name = "name";
    final Metadata metadata = MetadataBuilderFactory.metadataOf(id.toString(), name).build();
    assertThat(metadata.id(), is(id));
    assertThat(metadata.name(), is(name));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) UUID(java.util.UUID) Test(org.junit.Test)

Example 58 with Metadata

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

the class MetadataBuilderFactoryTest method shouldProvideMetadataBuilderWithRandomUuidAndDummyName.

@Test
public void shouldProvideMetadataBuilderWithRandomUuidAndDummyName() throws Exception {
    final Metadata metadata = MetadataBuilderFactory.metadataWithRandomUUIDAndName().build();
    assertThat(metadata.id(), notNullValue());
    assertThat(metadata.name(), is("dummy"));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Example 59 with Metadata

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

the class MetadataBuilderFactoryTest method shouldProvideMetadataBuilderFromMetadata.

@Test
public void shouldProvideMetadataBuilderFromMetadata() throws Exception {
    final UUID id = UUID.randomUUID();
    final String name = "name";
    final Metadata originalMetadata = JsonEnvelope.metadataBuilder().withId(id).withName(name).build();
    final Metadata metadata = MetadataBuilderFactory.metadataFrom(originalMetadata).build();
    assertThat(metadata.id(), notNullValue());
    assertThat(metadata.name(), is(name));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) UUID(java.util.UUID) Test(org.junit.Test)

Example 60 with Metadata

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

the class EventFilterInterceptorCodeGeneratorTest method nowTestTheGeneratedClass.

private void nowTestTheGeneratedClass(final Class<?> generatedClass) throws Exception {
    final String eventName = "an.event.name";
    final Interceptor interceptor = buildTheClassForTest(generatedClass, new MyCustomEventFilter(eventName));
    final InterceptorContext interceptorContext_1 = mock(InterceptorContext.class, "interceptorContext_1");
    final InterceptorContext interceptorContext_2 = mock(InterceptorContext.class, "interceptorContext_2");
    final InterceptorChain interceptorChain = mock(InterceptorChain.class);
    final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class);
    final Metadata metadata = mock(Metadata.class);
    when(interceptorContext_1.inputEnvelope()).thenReturn(jsonEnvelope);
    when(jsonEnvelope.metadata()).thenReturn(metadata);
    when(metadata.name()).thenReturn(eventName);
    when(interceptorChain.processNext(interceptorContext_1)).thenReturn(interceptorContext_2);
    assertThat(interceptor.process(interceptorContext_1, interceptorChain), is(interceptorContext_2));
}
Also used : InterceptorChain(uk.gov.justice.services.core.interceptor.InterceptorChain) InterceptorContext(uk.gov.justice.services.core.interceptor.InterceptorContext) Metadata(uk.gov.justice.services.messaging.Metadata) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Interceptor(uk.gov.justice.services.core.interceptor.Interceptor)

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