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());
}
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));
}
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));
}
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));
}
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));
}
Aggregations