@Test public void testRequestProducerAddingTokenCanBeCreated() { RequestBuilder builder = mock(RequestBuilder.class); RequestBuilder builderResult = mock(RequestBuilder.class); @SuppressWarnings("unchecked") Consumer<RequestBuilder> wrappedProducer = mock(Consumer.class); when(builder.header(HttpConstants.HEADER_AUTHORIZATION, AUTH_HEADER_VALUE)) .thenReturn(builderResult); AccessToken accessToken = new AccessToken(TOKEN); Consumer<RequestBuilder> producer = accessToken.tokenProducer(wrappedProducer); producer.accept(builder); verify(builder).header(HttpConstants.HEADER_AUTHORIZATION, AUTH_HEADER_VALUE); verify(wrappedProducer).accept(builderResult); }
public Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer) { return builder -> producer.accept(addToken(builder)); }
AccessToken { public Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer) { return builder -> producer.accept(addToken(builder)); } }
AccessToken { public Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer) { return builder -> producer.accept(addToken(builder)); } AccessToken(String token); }
AccessToken { public Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer) { return builder -> producer.accept(addToken(builder)); } AccessToken(String token); String getToken(); RequestBuilder addToken(RequestBuilder builder); Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer); @Override boolean equals(Object o); @Override int hashCode(); }
AccessToken { public Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer) { return builder -> producer.accept(addToken(builder)); } AccessToken(String token); String getToken(); RequestBuilder addToken(RequestBuilder builder); Consumer<RequestBuilder> tokenProducer(Consumer<? super RequestBuilder> producer); @Override boolean equals(Object o); @Override int hashCode();  }