AnalyticsRequestInterceptor implements RequestInterceptor { @Override public void intercept(RequestFacade request) { request.addHeader(AUTHORIZATION_HEADER, Credentials.basic(writeKey, "")); request.addHeader(USER_AGENT_HEADER, userAgent); } AnalyticsRequestInterceptor(@Nonnull String writeKey, @Nonnull String userAgent); @Override void intercept(RequestFacade request);  }
@Test public void interceptor() { RequestFacade requestFacade = mock(RequestFacade.class); AnalyticsRequestInterceptor interceptor = new AnalyticsRequestInterceptor("writeKey", "userAgent"); interceptor.intercept(requestFacade); verify(requestFacade).addHeader("Authorization", "Basic d3JpdGVLZXk6"); verify(requestFacade).addHeader("User-Agent", "userAgent"); }