RequestInterceptorProcessor extends ProcessorBase { @Override public void process(final WilmaHttpEntity entity) throws ApplicationException { Map<String, StubDescriptor> stubDescriptors = routingService.getStubDescriptors(); for (String groupName : stubDescriptors.keySet()) { StubDescriptor stubDescriptor = stubDescriptors.get(groupName); List<InterceptorDescriptor> interceptorDescriptors = stubDescriptor.getInterceptorDescriptors(); for (InterceptorDescriptor interceptorDescriptor : interceptorDescriptors) { RequestInterceptor interceptor = interceptorDescriptor.getRequestInterceptor(); callInterceptor(interceptor, entity, interceptorDescriptor); } } }  @Override void process(final WilmaHttpEntity entity);  }
@Test public void testProcessShouldCallAllResponseInterceptors() throws ApplicationException { Map<String, StubDescriptor> stubDescriptors = new LinkedHashMap<>(); stubDescriptors.put("test", createStubDescriptor()); given(routingService.getStubDescriptors()).willReturn(stubDescriptors); WilmaHttpEntity entity = new WilmaHttpRequest(); underTest.process(entity); BDDMockito.verify(requestInterceptor).onRequestReceive((WilmaHttpRequest) entity, PARAMS); }
@Test public void testProcessWhenThereAreNoInterceptorsShouldDoNothing() throws ApplicationException { Map<String, StubDescriptor> stubDescriptors = new LinkedHashMap<>(); stubDescriptors.put("test", createStubDescriptorWithNoInterceptor()); given(routingService.getStubDescriptors()).willReturn(stubDescriptors); WilmaHttpEntity entity = new WilmaHttpRequest(); underTest.process(entity); BDDMockito.verify(requestInterceptor, BDDMockito.never()).onRequestReceive((WilmaHttpRequest) entity, PARAMS); }