### Question:
ReportRequestFactoryHelper { @VisibleForTesting HttpRequestFactory getHttpRequestFactory(final String reportUrl, String version) throws AuthenticationException { final HttpHeaders httpHeaders = createHeaders(reportUrl, version); return httpTransport.createRequestFactory( request -> { request.setHeaders(httpHeaders); request.setConnectTimeout(reportDownloadTimeout); request.setReadTimeout(reportDownloadTimeout); request.setThrowExceptionOnExecuteError(false); request.setLoggingEnabled(true); request.setResponseInterceptor(responseInterceptor); }); } @Inject  ReportRequestFactoryHelper(AdWordsSession session,
      AuthorizationHeaderProvider authorizationHeaderProvider, UserAgentCombiner userAgentCombiner,
      HttpTransport httpTransport, AdWordsLibConfiguration adWordsLibConfiguration,
      ReportResponseInterceptor responseInterceptor); int getReportDownloadTimeout(); void setReportDownloadTimeout(int reportDownloadTimeout); static final String DOWNLOAD_SERVER_URI; }### Answer:
@Test public void testGetHttpRequestFactory() throws ValidationException, AuthenticationException, IOException { final int timeoutFromLibConfig = 42; when(adWordsLibConfiguration.getReportDownloadTimeout()).thenReturn(timeoutFromLibConfig); AdWordsSession session = new AdWordsSession.Builder() .withDeveloperToken("foodevtoken") .withClientCustomerId("fooclientcustomerid") .withOAuth2Credential(credential) .withUserAgent("userAgent") .withReportingConfiguration(reportingConfiguration) .build(); when(authorizationHeaderProvider.getAuthorizationHeader(session, ENDPOINT_URL.build())) .thenReturn("fooauthheader"); when(userAgentCombiner.getUserAgent(anyString())).thenReturn("foouseragent"); ReportRequestFactoryHelper helper = new ReportRequestFactoryHelper( session, authorizationHeaderProvider, userAgentCombiner, transport, adWordsLibConfiguration, reportResponseInterceptor); HttpRequestFactory requestFactory = helper.getHttpRequestFactory(ENDPOINT_URL.build(), version); HttpRequest request = requestFactory.buildPostRequest( ENDPOINT_URL, new AwqlReportBodyProvider("select 1", "csv").getHttpContent()); HttpHeaders headers = request.getHeaders(); assertEquals("foodevtoken", headers.get("developerToken")); assertEquals("fooauthheader", headers.getAuthorization()); assertEquals("fooclientcustomerid", headers.get("clientCustomerId")); assertTrue((headers.getUserAgent()).contains("foouseragent")); if (reportingConfiguration == null) { assertFalse( "skipReportHeader should not be in the header if no reporting config is set", headers.containsKey("skipReportHeader")); assertFalse( "skipReportSummary should not be in the header if no reporting config is set", headers.containsKey("skipReportSummary")); assertEquals( "connect timeout is incorrect", timeoutFromLibConfig, request.getConnectTimeout()); assertEquals("read timeout is incorrect", timeoutFromLibConfig, request.getReadTimeout()); } else { Integer expectedTimeout = reportingConfiguration.getReportDownloadTimeout(); if (expectedTimeout == null) { expectedTimeout = timeoutFromLibConfig; } assertEquals( "connect timeout is incorrect", expectedTimeout.intValue(), request.getConnectTimeout()); assertEquals( "read timeout is incorrect", expectedTimeout.intValue(), request.getReadTimeout()); assertEquals( "skipReportHeader not equal to the reporting config setting", toStringBoolean(reportingConfiguration.isSkipReportHeader()), headers.get("skipReportHeader")); assertEquals( "skipColumnHeader not equal to the reporting config setting", toStringBoolean(reportingConfiguration.isSkipColumnHeader()), headers.get("skipColumnHeader")); assertEquals( "skipReportSummary not equal to the reporting config setting", toStringBoolean(reportingConfiguration.isSkipReportSummary()), headers.get("skipReportSummary")); assertEquals( "includeZeroImpressions not equal to the reporting config setting", toStringBoolean(reportingConfiguration.isIncludeZeroImpressions()), headers.get("includeZeroImpressions")); assertEquals( "useRawEnumValues not equal to the reporting config setting", toStringBoolean(reportingConfiguration.isUseRawEnumValues()), headers.get("useRawEnumValues")); } }