@Test public void should_return_all_headers() { HttpHeadersProvider provider = new CompositeHttpHeadersProvider(asList(i -> { HttpHeaders headers = new HttpHeaders(); headers.set("a", "1"); headers.set("b", "2-a"); return headers; }, i -> { HttpHeaders headers = new HttpHeaders(); headers.set("b", "2-b"); headers.set("c", "3"); return headers; })); HttpHeaders headers = provider.getHeaders(null); assertThat(headers.get("a")).isEqualTo(singletonList("1")); assertThat(headers.get("b")).isEqualTo(asList("2-a", "2-b")); assertThat(headers.get("c")).isEqualTo(singletonList("3")); }
@Override public HttpHeaders getHeaders(Instance instance) { HttpHeaders headers = new HttpHeaders(); delegates.forEach(delegate -> headers.addAll(delegate.getHeaders(instance))); return headers; }
CompositeHttpHeadersProvider implements HttpHeadersProvider { @Override public HttpHeaders getHeaders(Instance instance) { HttpHeaders headers = new HttpHeaders(); delegates.forEach(delegate -> headers.addAll(delegate.getHeaders(instance))); return headers; } }
CompositeHttpHeadersProvider implements HttpHeadersProvider { @Override public HttpHeaders getHeaders(Instance instance) { HttpHeaders headers = new HttpHeaders(); delegates.forEach(delegate -> headers.addAll(delegate.getHeaders(instance))); return headers; } CompositeHttpHeadersProvider(Collection<HttpHeadersProvider> delegates); }
CompositeHttpHeadersProvider implements HttpHeadersProvider { @Override public HttpHeaders getHeaders(Instance instance) { HttpHeaders headers = new HttpHeaders(); delegates.forEach(delegate -> headers.addAll(delegate.getHeaders(instance))); return headers; } CompositeHttpHeadersProvider(Collection<HttpHeadersProvider> delegates); @Override HttpHeaders getHeaders(Instance instance); }
CompositeHttpHeadersProvider implements HttpHeadersProvider { @Override public HttpHeaders getHeaders(Instance instance) { HttpHeaders headers = new HttpHeaders(); delegates.forEach(delegate -> headers.addAll(delegate.getHeaders(instance))); return headers; } CompositeHttpHeadersProvider(Collection<HttpHeadersProvider> delegates); @Override HttpHeaders getHeaders(Instance instance);  }