InterceptorChainProcessorProducer { @Produces public InterceptorChainProcessor produceProcessor(final InjectionPoint injectionPoint) { trace(logger, () -> format("Interceptor Chain Processor provided for %s", injectionPoint.getClass().getName())); final String component = componentNameExtractor.componentFrom(injectionPoint); return new DefaultInterceptorChainProcessor(interceptorCache, dispatcherCache.dispatcherFor(injectionPoint)::dispatch, component); }  @Produces InterceptorChainProcessor produceProcessor(final InjectionPoint injectionPoint); InterceptorChainProcessor produceLocalProcessor(final String component);  }
@Test public void shouldProduceProcessorThatDispatchesEnvelope_FromAdapter() throws Exception { when(interceptorCache.getInterceptors("EVENT_LISTENER")).thenReturn(envelopeRecordingInterceptor()); final MemberInjectionPoint injectionPoint = injectionPointWith(EventListenerAdapter.class.getDeclaredField("processor")); 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)); }
@Test public void shouldProduceProcessorThatDispatchesEnvelope_FromDirectAdapter() throws Exception { when(interceptorCache.getInterceptors("QUERY_API")).thenReturn(envelopeRecordingInterceptor()); final MemberInjectionPoint injectionPoint = injectionPointWith(QueryApiDirectAdapter.class.getDeclaredField("processor")); 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)); }