@Test
  public void loadAd_shouldPropagateLocationInLocalExtras() throws Exception {
    Location expectedLocation = new Location("");
    expectedLocation.setLongitude(10.0);
    expectedLocation.setLongitude(20.1);

    stub(moPubView.getLocation()).toReturn(expectedLocation);
    subject = new CustomEventBannerAdapter(moPubView, CLASS_NAME, null);
    subject.loadAd();

    expectedLocalExtras.put("location", moPubView.getLocation());

    verify(banner)
        .loadBanner(
            any(Context.class), eq(subject), eq(expectedLocalExtras), eq(expectedServerExtras));
  }
  public CustomEventBannerAdapter(MoPubView moPubView, String className, String classData) {
    mHandler = new Handler();
    mMoPubView = moPubView;
    mContext = moPubView.getContext();
    mLocalExtras = new HashMap<String, Object>();
    mServerExtras = new HashMap<String, String>();
    mTimeout =
        new Runnable() {
          @Override
          public void run() {
            Log.d("MoPub", "Third-party network timed out.");
            onBannerFailed(NETWORK_TIMEOUT);
            invalidate();
          }
        };

    Log.d("MoPub", "Attempting to invoke custom event: " + className);
    try {
      mCustomEventBanner = CustomEventBannerFactory.create(className);
    } catch (Exception exception) {
      Log.d("MoPub", "Couldn't locate or instantiate custom event: " + className + ".");
      mMoPubView.loadFailUrl(ADAPTER_NOT_FOUND);
      return;
    }

    // Attempt to load the JSON extras into mServerExtras.
    try {
      mServerExtras = Json.jsonStringToMap(classData);
    } catch (Exception exception) {
      Log.d("MoPub", "Failed to create Map from JSON: " + classData + exception.toString());
    }

    mLocalExtras = mMoPubView.getLocalExtras();
    if (mMoPubView.getLocation() != null) {
      mLocalExtras.put("location", mMoPubView.getLocation());
    }
    if (mMoPubView.getAdViewController() != null) {
      mLocalExtras.put(AD_CONFIGURATION_KEY, mMoPubView.getAdViewController().getAdConfiguration());
    }
  }