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