HttpClient { public static HttpGet initializeHttpGet(final String url, final Context context) { final HttpGet httpGet = new HttpGet(url); if (getWebViewUserAgent() == null && context != null) { setWebViewUserAgent(new WebView(context).getSettings().getUserAgentString()); } final String webViewUserAgent = getWebViewUserAgent(); if (webViewUserAgent != null) { httpGet.addHeader(USER_AGENT.getKey(), webViewUserAgent); } return httpGet; }  static AndroidHttpClient getHttpClient(); static HttpGet initializeHttpGet(final String url, final Context context); static void makeTrackingHttpRequest(final Iterable<String> urls, final Context context); static void makeTrackingHttpRequest(final Iterable<String> urls,
            final Context context,
            final MoPubEvents.Type type); static void makeTrackingHttpRequest(final String url,
            final Context context); static void makeTrackingHttpRequest(final String url,
            final Context context,
            final MoPubEvents.Type type); synchronized static String getWebViewUserAgent(String defaultUserAgent); synchronized static String getWebViewUserAgent(); synchronized static void setWebViewUserAgent(final String userAgent);  }
@Test public void initializeHttpGet_shouldReturnHttpGetWithWebViewUserAgent() throws Exception { HttpGet httpGet = initializeHttpGet(url, context); assertThat(httpGet.getURI().toURL().toString()).isEqualTo(url); assertThat(httpGet.getFirstHeader(ResponseHeader.USER_AGENT.getKey()).getValue()).isEqualTo(userAgent); }
@Test(expected = NullPointerException.class) public void initializeHttpGet_withNullUrl_shouldThrowNullPointerException() throws Exception { HttpGet httpGet = initializeHttpGet(null, context); }
@Test public void initializeHttpGet_withNullContext_shouldNotPopulateUserAgentHeader() throws Exception { HttpGet httpGet = initializeHttpGet(url, null); assertThat(httpGet.getURI().toURL().toString()).isEqualTo(url); assertThat(httpGet.getFirstHeader(ResponseHeader.USER_AGENT.getKey())).isNull(); }