@Override
    public void prepareTest(Object test) {
      ClientMetadata.clearForTesting();

      DateAndTime.setInstance(new TestDateAndTime());
      CustomEventBannerFactory.setInstance(new TestCustomEventBannerFactory());
      CustomEventInterstitialFactory.setInstance(new TestCustomEventInterstitialFactory());
      CustomEventBannerAdapterFactory.setInstance(new TestCustomEventBannerAdapterFactory());
      MoPubViewFactory.setInstance(new TestMoPubViewFactory());
      CustomEventInterstitialAdapterFactory.setInstance(
          new TestCustomEventInterstitialAdapterFactory());
      HtmlBannerWebViewFactory.setInstance(new TestHtmlBannerWebViewFactory());
      HtmlInterstitialWebViewFactory.setInstance(new TestHtmlInterstitialWebViewFactory());
      AdViewControllerFactory.setInstance(new TestAdViewControllerFactory());
      VastManagerFactory.setInstance(new TestVastManagerFactory());
      MethodBuilderFactory.setInstance(new TestMethodBuilderFactory());
      CustomEventNativeFactory.setInstance(new TestCustomEventNativeFactory());
      MraidControllerFactory.setInstance(new TestMraidControllerFactory());

      ShadowAsyncTasks.reset();
      ShadowMoPubHttpUrlConnection.reset();
      MoPubEvents.setEventDispatcher(mock(EventDispatcher.class));
      MoPub.setLocationAwareness(LocationAwareness.NORMAL);
      MoPub.setLocationPrecision(6);

      MockitoAnnotations.initMocks(test);

      AsyncTasks.setExecutor(new RoboExecutorService());
      CacheService.clearAndNullCaches();
    }
  @Override
  public String generateUrlString(String serverHostname) {
    initUrlString(serverHostname, Constants.AD_HANDLER);

    setApiVersion("6");

    final ClientMetadata clientMetadata = ClientMetadata.getInstance(mContext);
    addBaseParams(clientMetadata);

    setMraidFlag(true);

    setExternalStoragePermission(mIsStorePictureSupported);

    return getFinalUrlString();
  }
 @Override
 public void afterTest(final Method method) {
   ClientMetadata.clearForTesting();
 }
  @Override
  public String generateUrlString(String serverHostname) {
    initUrlString(serverHostname, Constants.AD_HANDLER);

    final ClientMetadata clientMetadata = ClientMetadata.getInstance(mContext);

    setApiVersion("6");

    setAdUnitId(mAdUnitId);

    setSdkVersion(clientMetadata.getSdkVersion());

    setDeviceInfo(
        clientMetadata.getDeviceManufacturer(),
        clientMetadata.getDeviceModel(),
        clientMetadata.getDeviceProduct());

    setKeywords(mKeywords);

    setLocation(mLocation);

    setTimezone(DateAndTime.getTimeZoneOffsetString());

    setOrientation(clientMetadata.getOrientationString());

    setDensity(clientMetadata.getDensity());

    setMraidFlag(true);

    String networkOperator = clientMetadata.getNetworkOperatorForUrl();
    setMccCode(networkOperator);
    setMncCode(networkOperator);

    setIsoCountryCode(clientMetadata.getIsoCountryCode());
    setCarrierName(clientMetadata.getNetworkOperatorName());

    setNetworkType(clientMetadata.getActiveNetworkType());

    setAppVersion(clientMetadata.getAppVersion());

    setExternalStoragePermission(mIsStorePictureSupported);

    setTwitterAppInstalledFlag();

    appendAdvertisingInfoTemplates();

    return getFinalUrlString();
  }