### Question:
RequestAuthInterceptor implements Interceptor { @Override public Response intercept(@NonNull Chain chain) throws IOException { final String token = authenticator.getAccessToken(); if (token.isEmpty()) { return chain.proceed(chain.request()); } final Request.Builder requestBuilder = chain.request().newBuilder(); final String authorization = Headers.AUTH_BEARER + token; requestBuilder.addHeader(Headers.AUTHORIZATION, authorization); return chain.proceed(requestBuilder.build()); } @Inject  RequestAuthInterceptor(AccountAuthenticator authenticator); @Override Response intercept(@NonNull Chain chain);  }### Answer:
@Test public void authHeaderGetsAdded() throws Exception { String accessToken = "valid"; when(authenticator.getAccessToken()).thenAnswer(invocation -> accessToken); Response response = interceptor.intercept(chain); Assert.assertEquals("Bearer " + accessToken, response.request().header("Authorization")); }
@Test public void emptyAuthHeaderIgnored() throws Exception { String accessToken = ""; when(authenticator.getAccessToken()).thenAnswer(invocation -> accessToken); Response response = interceptor.intercept(chain); Assert.assertNull(response.request().header("Authorization")); }