Search in sources :

Example 21 with Metadata

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

the class HandlerMethodTest method shouldHandlePojoAsynchronously.

@Test
public void shouldHandlePojoAsynchronously() {
    final TestPojo testPojo = new TestPojo();
    final Metadata metadata = Envelope.metadataBuilder().withId(UUID.randomUUID()).withName("test").build();
    final Envelope<TestPojo> testPojoEnvelope = Envelope.envelopeFrom(metadata, testPojo);
    Object result = asyncPojoHandlerInstance().execute(testPojoEnvelope);
    assertThat(result, nullValue());
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Test(org.junit.Test)

Example 22 with Metadata

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

the class MetadataBuilderFactoryTest method shouldProvideMetadataBuilderWithRandomUuidAndDummyNameAndCreatedAt.

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

Example 23 with Metadata

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

the class MetadataBuilderFactoryTest method shouldProvideMetadataBuilderWithRandomUuidAndName.

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

Example 24 with Metadata

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

the class MetadataBuilderFactoryTest method shouldProvideMetadataBuilderFromJsonObject.

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

Example 25 with Metadata

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

the class EventFilterInterceptorCodeGeneratorTest method nowTestTheFailureCase.

private void nowTestTheFailureCase(final Class<?> generatedClass) throws Exception {
    final String eventName = "an.event.name";
    final String aDifferentventName = "a.different.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(aDifferentventName);
    when(interceptorChain.processNext(interceptorContext_1)).thenReturn(interceptorContext_2);
    assertThat(interceptor.process(interceptorContext_1, interceptorChain), is(interceptorContext_1));
}
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