CachingHttpRequest implements ForwardingHttpRequest { @Override public HttpHeaders getHeaders() { return headers.get(); } CachingHttpRequest(final HttpRequest request); @Override HttpRequest delegate(); @Override HttpHeaders getHeaders();  }
@Test void shouldDelegate() { final CachingHttpRequest unit = new CachingHttpRequest(MockHttpRequest.create()); assertThat(unit.getHeaders(), is(anEmptyMap())); }
@Test void shouldCache() { final HttpRequest delegate = mock(HttpRequest.class); when(delegate.getHeaders()).thenReturn(HttpHeaders.empty()); final CachingHttpRequest unit = new CachingHttpRequest(delegate); unit.getHeaders(); unit.getHeaders(); verify(delegate, atMost(1)).getHeaders(); }