Search in sources :

Example 1 with ObjectMapperProducer

use of uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer in project microservice_framework by CJSCommonPlatform.

the class EnveloperFactory method create.

public DefaultEnveloper create() {
    final ObjectMapper objectMapper = new ObjectMapperProducer().objectMapper();
    final ObjectToJsonValueConverter converter = new ObjectToJsonValueConverter(objectMapper);
    return new DefaultEnveloper(new UtcClock(), converter);
}
Also used : UtcClock(uk.gov.justice.services.common.util.UtcClock) ObjectMapperProducer(uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer) ObjectToJsonValueConverter(uk.gov.justice.services.common.converter.ObjectToJsonValueConverter) DefaultEnveloper(uk.gov.justice.services.core.enveloper.DefaultEnveloper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ObjectMapperProducer

use of uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer in project microservice_framework by CJSCommonPlatform.

the class DispatcherTest method setup.

@Before
public void setup() {
    handlerRegistry = new HandlerRegistry(logger);
    dispatcher = new Dispatcher(handlerRegistry, new EnvelopePayloadTypeConverter(new ObjectMapperProducer().objectMapper()), new JsonEnvelopeRepacker());
}
Also used : HandlerRegistry(uk.gov.justice.services.core.handler.registry.HandlerRegistry) ObjectMapperProducer(uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer) Before(org.junit.Before)

Example 3 with ObjectMapperProducer

use of uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer in project microservice_framework by CJSCommonPlatform.

the class InterceptorChainProcessorProducerTest method setUp.

@Before
public void setUp() throws Exception {
    interceptorChainProcessorProducer.dispatcherCache = new DispatcherCache(new DispatcherFactory(new EnvelopePayloadTypeConverter(new ObjectMapperProducer().objectMapper()), new JsonEnvelopeRepacker()));
    envelopeRecordingInterceptor.reset();
}
Also used : DispatcherFactory(uk.gov.justice.services.core.dispatcher.DispatcherFactory) DispatcherCache(uk.gov.justice.services.core.dispatcher.DispatcherCache) ObjectMapperProducer(uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer) JsonEnvelopeRepacker(uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker) EnvelopePayloadTypeConverter(uk.gov.justice.services.core.dispatcher.EnvelopePayloadTypeConverter) Before(org.junit.Before)

Example 4 with ObjectMapperProducer

use of uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer in project microservice_framework by CJSCommonPlatform.

the class DefaultEnveloperProviderTest method shouldDelegateToDefaultEnveloperFromCdiToEnvelopeWithMetadateFrom.

@Test
public void shouldDelegateToDefaultEnveloperFromCdiToEnvelopeWithMetadateFrom() throws Exception {
    final DefaultEnveloper enveloper = new DefaultEnveloper(new UtcClock(), new ObjectToJsonValueConverter(new ObjectMapperProducer().objectMapper()));
    enveloper.register(new EventFoundEvent(DefaultEnveloperProviderTest.TestEvent.class, TEST_EVENT_NAME));
    final Metadata metadata = createMetadata();
    final TestPojo payload = new TestPojo(TEST_EVENT_NAME);
    final Envelope<TestPojo> envelope = envelopeFrom(metadata, payload);
    final Function<Object, JsonEnvelope> envelope1 = new DefaultEnveloperProvider().toEnvelopeWithMetadataFrom(envelope);
    final TestEvent testEvent = new TestEvent();
    assertThat(envelope1.apply(testEvent).metadata().name(), is(metadata.name()));
    assertThat(envelope.payload(), is(payload));
}
Also used : UtcClock(uk.gov.justice.services.common.util.UtcClock) Metadata(uk.gov.justice.services.messaging.Metadata) ObjectToJsonValueConverter(uk.gov.justice.services.common.converter.ObjectToJsonValueConverter) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) ObjectMapperProducer(uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer) EventFoundEvent(uk.gov.justice.services.core.extension.EventFoundEvent) DefaultEnveloper(uk.gov.justice.services.core.enveloper.DefaultEnveloper) Test(org.junit.Test)

Aggregations

ObjectMapperProducer (uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer)4 Before (org.junit.Before)2 ObjectToJsonValueConverter (uk.gov.justice.services.common.converter.ObjectToJsonValueConverter)2 UtcClock (uk.gov.justice.services.common.util.UtcClock)2 DefaultEnveloper (uk.gov.justice.services.core.enveloper.DefaultEnveloper)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Test (org.junit.Test)1 DispatcherCache (uk.gov.justice.services.core.dispatcher.DispatcherCache)1 DispatcherFactory (uk.gov.justice.services.core.dispatcher.DispatcherFactory)1 EnvelopePayloadTypeConverter (uk.gov.justice.services.core.dispatcher.EnvelopePayloadTypeConverter)1 JsonEnvelopeRepacker (uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker)1 EventFoundEvent (uk.gov.justice.services.core.extension.EventFoundEvent)1 HandlerRegistry (uk.gov.justice.services.core.handler.registry.HandlerRegistry)1 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)1 Metadata (uk.gov.justice.services.messaging.Metadata)1