Search in sources :

Example 1 with MemberInjectionPoint

use of uk.gov.justice.services.test.utils.common.MemberInjectionPoint in project microservice_framework by CJSCommonPlatform.

the class InterceptorChainProcessorProducerTest method shouldProduceProcessorThatDispatchesEnvelope_FromDirectAdapter.

@Test
public void shouldProduceProcessorThatDispatchesEnvelope_FromDirectAdapter() throws Exception {
    when(interceptorCache.getInterceptors("QUERY_API")).thenReturn(envelopeRecordingInterceptor());
    final MemberInjectionPoint injectionPoint = injectionPointWith(QueryApiDirectAdapter.class.getDeclaredField("processor"));
    interceptorChainProcessorProducer.dispatcherCache.dispatcherFor(injectionPoint).register(envelopeRecordingHandler);
    final InterceptorChainProcessor processor = interceptorChainProcessorProducer.produceProcessor(injectionPoint);
    final JsonEnvelope dispatchedEnvelope = envelopeFrom(metadataBuilder().withId(randomUUID()).withName(ACTION_NAME), createObjectBuilder());
    processor.process(interceptorContextWithInput(dispatchedEnvelope));
    assertThat(envelopeRecordingInterceptor.firstRecordedEnvelope(), is(dispatchedEnvelope));
    assertThat(envelopeRecordingHandler.firstRecordedEnvelope(), is(dispatchedEnvelope));
}
Also used : MemberInjectionPoint(uk.gov.justice.services.test.utils.common.MemberInjectionPoint) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Example 2 with MemberInjectionPoint

use of uk.gov.justice.services.test.utils.common.MemberInjectionPoint in project microservice_framework by CJSCommonPlatform.

the class InterceptorChainProcessorProducerTest method shouldProduceProcessorThatDispatchesEnvelope_FromAdapter.

@Test
public void shouldProduceProcessorThatDispatchesEnvelope_FromAdapter() throws Exception {
    when(interceptorCache.getInterceptors("EVENT_LISTENER")).thenReturn(envelopeRecordingInterceptor());
    final MemberInjectionPoint injectionPoint = injectionPointWith(EventListenerAdapter.class.getDeclaredField("processor"));
    interceptorChainProcessorProducer.dispatcherCache.dispatcherFor(injectionPoint).register(envelopeRecordingHandler);
    final InterceptorChainProcessor processor = interceptorChainProcessorProducer.produceProcessor(injectionPoint);
    final JsonEnvelope dispatchedEnvelope = envelopeFrom(metadataBuilder().withId(randomUUID()).withName(ACTION_NAME), createObjectBuilder());
    processor.process(interceptorContextWithInput(dispatchedEnvelope));
    assertThat(envelopeRecordingInterceptor.firstRecordedEnvelope(), is(dispatchedEnvelope));
    assertThat(envelopeRecordingHandler.firstRecordedEnvelope(), is(dispatchedEnvelope));
}
Also used : MemberInjectionPoint(uk.gov.justice.services.test.utils.common.MemberInjectionPoint) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)2 MemberInjectionPoint (uk.gov.justice.services.test.utils.common.MemberInjectionPoint)2