InterceptorChainImpl implements InterceptorChain { @Override public InternalResponse<Object> proceed(InternalRequest<Object> request, InternalResponse<Object> response) throws Exception { requireNonNull(request); Interceptor interceptor = interceptors.poll(); if (nonNull(interceptor)) { return interceptor.around(this, request, response); } return route.execute(request, response); } InterceptorChainImpl(InternalRoute route); @Override InternalResponse<Object> proceed(InternalRequest<Object> request, InternalResponse<Object> response); @Override InternalRoute getRoute();  }
@Test public void success_proceed() throws Exception { InternalRoute route = basicRoute(); route.interceptor(new FirstInterceptor()); route.interceptor(new SecondInterceptor()); route.interceptor(new ThirdInterceptor()); InternalRequest<Object> request = new RequestStub(); InternalResponse<Object> response = new ResponseStub(); InterceptorChain chain = new InterceptorChainImpl(route); chain.proceed(request, response); assertEquals(0, request.getHeaders().size()); assertEquals(HttpStatus.CONFLICT, response.getStatus()); }
@Test public void swallowed_proceed() throws Exception { InternalRoute route = basicRoute(); route.interceptor(new SwallowInterceptor()); InternalRequest<Object> request = new RequestStub(); InternalResponse<Object> response = new ResponseStub(); InterceptorChain chain = new InterceptorChainImpl(route); chain.proceed(request, response); assertEquals("YES", request.getHeaders().get(HeaderName.of("Swallowed"))); assertNull(response.getStatus()); }