Search in sources :

Example 1 with ObjectToJsonValueConverter

use of uk.gov.justice.services.common.converter.ObjectToJsonValueConverter 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 ObjectToJsonValueConverter

use of uk.gov.justice.services.common.converter.ObjectToJsonValueConverter 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

ObjectToJsonValueConverter (uk.gov.justice.services.common.converter.ObjectToJsonValueConverter)2 ObjectMapperProducer (uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer)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 EventFoundEvent (uk.gov.justice.services.core.extension.EventFoundEvent)1 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)1 Metadata (uk.gov.justice.services.messaging.Metadata)1