AccessToken { public RequestBuilder addToken(RequestBuilder builder) { return builder.header(HttpConstants.HEADER_AUTHORIZATION, HttpConstants.AUTH_BEARER + getToken()); } AccessToken(String token); String getToken(); RequestBuilder addToken(RequestBuilder builder); Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testTokenIsAddedToRequestBuilder() { RequestBuilder builder = mock(RequestBuilder.class); RequestBuilder builderResult = mock(RequestBuilder.class); when(builder.header(HttpConstants.HEADER_AUTHORIZATION, AUTH_HEADER_VALUE)) .thenReturn(builderResult); AccessToken accessToken = new AccessToken(TOKEN); assertThat(accessToken.addToken(builder)).isEqualTo(builderResult); }