TenantContextHeaderInterceptor implements ClientHttpRequestInterceptor { public void setHeaderName(String headerName) { this.headerName = headerName; }  @Override ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution); void setHeaderName(String headerName);  }
@Test public void shouldSetHeaderOnRequest() { this.interceptor.setHeaderName("context"); List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(); interceptors.add(this.interceptor); RestTemplate template = new RestTemplate(); template.setInterceptors(interceptors); MockRestServiceServer mockServer = MockRestServiceServer.createServer(template); mockServer.expect(requestTo("/test")) .andExpect(method(GET)) .andExpect(header("context", "test-context")) .andRespond(MockRestResponseCreators.withSuccess()); TenantContextTestUtil.setCurrentTenant("test-context"); HttpEntity entity = new HttpEntity(null, null); template.exchange("/test", GET, entity, String.class); mockServer.verify(); }