Search in sources :

Example 1 with JsonEnvelopeRepacker

use of uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker 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 2 with JsonEnvelopeRepacker

use of uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker in project microservice_framework by CJSCommonPlatform.

the class SenderProducerTest method shouldCreateANewSenderDispatcherDelegate.

@Test
public void shouldCreateANewSenderDispatcherDelegate() throws Exception {
    final InjectionPoint injectionPoint = mock(InjectionPoint.class);
    final Dispatcher dispatcher = mock(Dispatcher.class);
    when(dispatcherCache.dispatcherFor(injectionPoint)).thenReturn(dispatcher);
    final DispatcherDelegate dispatcherDelegate = (DispatcherDelegate) senderProducer.produceSender(injectionPoint);
    assertThat(privateField("dispatcher", dispatcherDelegate, Dispatcher.class), is(dispatcher));
    assertThat(privateField("systemUserUtil", dispatcherDelegate, SystemUserUtil.class), is(systemUserUtil));
    assertThat(privateField("envelopePayloadTypeConverter", dispatcherDelegate, EnvelopePayloadTypeConverter.class), is(envelopePayloadTypeConverter));
    assertThat(privateField("jsonEnvelopeRepacker", dispatcherDelegate, JsonEnvelopeRepacker.class), is(jsonEnvelopeRepacker));
    final RequestResponseEnvelopeValidator requestResponseEnvelopeValidator = privateField("requestResponseEnvelopeValidator", dispatcherDelegate, RequestResponseEnvelopeValidator.class);
    assertThat(privateField("nameToMediaTypeConverter", requestResponseEnvelopeValidator, NameToMediaTypeConverter.class), is(nameToMediaTypeConverter));
    assertThat(privateField("mediaTypeProvider", requestResponseEnvelopeValidator, MediaTypeProvider.class), is(mediaTypeProvider));
    assertThat(privateField("envelopeInspector", requestResponseEnvelopeValidator, EnvelopeInspector.class), is(envelopeInspector));
    final EnvelopeValidator envelopeValidator = privateField("envelopeValidator", requestResponseEnvelopeValidator, EnvelopeValidator.class);
    assertThat(privateField("jsonSchemaValidator", envelopeValidator, JsonSchemaValidator.class), is(jsonSchemaValidator));
    assertThat(privateField("objectMapper", envelopeValidator, ObjectMapper.class), is(objectMapper));
    assertThat(privateField("envelopeValidationExceptionHandler", envelopeValidator, EnvelopeValidationExceptionHandler.class), is(envelopeValidationExceptionHandler));
}
Also used : RequestResponseEnvelopeValidator(uk.gov.justice.services.core.envelope.RequestResponseEnvelopeValidator) EnvelopeValidationExceptionHandler(uk.gov.justice.services.core.envelope.EnvelopeValidationExceptionHandler) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) SystemUserUtil(uk.gov.justice.services.core.dispatcher.SystemUserUtil) Dispatcher(uk.gov.justice.services.core.dispatcher.Dispatcher) EnvelopePayloadTypeConverter(uk.gov.justice.services.core.dispatcher.EnvelopePayloadTypeConverter) NameToMediaTypeConverter(uk.gov.justice.services.core.mapping.NameToMediaTypeConverter) DispatcherDelegate(uk.gov.justice.services.core.dispatcher.DispatcherDelegate) MediaTypeProvider(uk.gov.justice.services.core.envelope.MediaTypeProvider) EnvelopeValidator(uk.gov.justice.services.core.envelope.EnvelopeValidator) RequestResponseEnvelopeValidator(uk.gov.justice.services.core.envelope.RequestResponseEnvelopeValidator) JsonEnvelopeRepacker(uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker) EnvelopeInspector(uk.gov.justice.services.core.envelope.EnvelopeInspector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonSchemaValidator(uk.gov.justice.services.core.json.JsonSchemaValidator) Test(org.junit.Test)

Example 3 with JsonEnvelopeRepacker

use of uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker in project microservice_framework by CJSCommonPlatform.

the class RequesterProducerTest method requesterShouldDelegateAdminRequestSubstitutingUserId.

@Test
public void requesterShouldDelegateAdminRequestSubstitutingUserId() throws Exception {
    final InjectionPoint injectionPoint = mock(InjectionPoint.class);
    final Dispatcher dispatcher = mock(Dispatcher.class);
    when(dispatcherCache.dispatcherFor(injectionPoint)).thenReturn(dispatcher);
    final DispatcherDelegate dispatcherDelegate = (DispatcherDelegate) requesterProducer.produceRequester(injectionPoint);
    assertThat(privateField("dispatcher", dispatcherDelegate, Dispatcher.class), is(dispatcher));
    assertThat(privateField("systemUserUtil", dispatcherDelegate, SystemUserUtil.class), is(systemUserUtil));
    assertThat(privateField("envelopePayloadTypeConverter", dispatcherDelegate, EnvelopePayloadTypeConverter.class), is(envelopePayloadTypeConverter));
    assertThat(privateField("jsonEnvelopeRepacker", dispatcherDelegate, JsonEnvelopeRepacker.class), is(jsonEnvelopeRepacker));
    final RequestResponseEnvelopeValidator requestResponseEnvelopeValidator = privateField("requestResponseEnvelopeValidator", dispatcherDelegate, RequestResponseEnvelopeValidator.class);
    assertThat(privateField("nameToMediaTypeConverter", requestResponseEnvelopeValidator, NameToMediaTypeConverter.class), is(nameToMediaTypeConverter));
    assertThat(privateField("mediaTypeProvider", requestResponseEnvelopeValidator, MediaTypeProvider.class), is(mediaTypeProvider));
    assertThat(privateField("envelopeInspector", requestResponseEnvelopeValidator, EnvelopeInspector.class), is(envelopeInspector));
    final EnvelopeValidator envelopeValidator = privateField("envelopeValidator", requestResponseEnvelopeValidator, EnvelopeValidator.class);
    assertThat(privateField("jsonSchemaValidator", envelopeValidator, JsonSchemaValidator.class), is(jsonSchemaValidator));
    assertThat(privateField("objectMapper", envelopeValidator, ObjectMapper.class), is(objectMapper));
    assertThat(privateField("envelopeValidationExceptionHandler", envelopeValidator, EnvelopeValidationExceptionHandler.class), is(envelopeValidationExceptionHandler));
}
Also used : RequestResponseEnvelopeValidator(uk.gov.justice.services.core.envelope.RequestResponseEnvelopeValidator) EnvelopeValidationExceptionHandler(uk.gov.justice.services.core.envelope.EnvelopeValidationExceptionHandler) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) SystemUserUtil(uk.gov.justice.services.core.dispatcher.SystemUserUtil) Dispatcher(uk.gov.justice.services.core.dispatcher.Dispatcher) EnvelopePayloadTypeConverter(uk.gov.justice.services.core.dispatcher.EnvelopePayloadTypeConverter) NameToMediaTypeConverter(uk.gov.justice.services.core.mapping.NameToMediaTypeConverter) DispatcherDelegate(uk.gov.justice.services.core.dispatcher.DispatcherDelegate) MediaTypeProvider(uk.gov.justice.services.core.envelope.MediaTypeProvider) EnvelopeValidator(uk.gov.justice.services.core.envelope.EnvelopeValidator) RequestResponseEnvelopeValidator(uk.gov.justice.services.core.envelope.RequestResponseEnvelopeValidator) JsonEnvelopeRepacker(uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker) EnvelopeInspector(uk.gov.justice.services.core.envelope.EnvelopeInspector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonSchemaValidator(uk.gov.justice.services.core.json.JsonSchemaValidator) Test(org.junit.Test)

Aggregations

EnvelopePayloadTypeConverter (uk.gov.justice.services.core.dispatcher.EnvelopePayloadTypeConverter)3 JsonEnvelopeRepacker (uk.gov.justice.services.core.dispatcher.JsonEnvelopeRepacker)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)2 Test (org.junit.Test)2 Dispatcher (uk.gov.justice.services.core.dispatcher.Dispatcher)2 DispatcherDelegate (uk.gov.justice.services.core.dispatcher.DispatcherDelegate)2 SystemUserUtil (uk.gov.justice.services.core.dispatcher.SystemUserUtil)2 EnvelopeInspector (uk.gov.justice.services.core.envelope.EnvelopeInspector)2 EnvelopeValidationExceptionHandler (uk.gov.justice.services.core.envelope.EnvelopeValidationExceptionHandler)2 EnvelopeValidator (uk.gov.justice.services.core.envelope.EnvelopeValidator)2 MediaTypeProvider (uk.gov.justice.services.core.envelope.MediaTypeProvider)2 RequestResponseEnvelopeValidator (uk.gov.justice.services.core.envelope.RequestResponseEnvelopeValidator)2 JsonSchemaValidator (uk.gov.justice.services.core.json.JsonSchemaValidator)2 NameToMediaTypeConverter (uk.gov.justice.services.core.mapping.NameToMediaTypeConverter)2 Before (org.junit.Before)1 ObjectMapperProducer (uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer)1 DispatcherCache (uk.gov.justice.services.core.dispatcher.DispatcherCache)1 DispatcherFactory (uk.gov.justice.services.core.dispatcher.DispatcherFactory)1