Search in sources :

Example 36 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class GamBannerEventHandler method handleAdFailure.

private void handleAdFailure(int errorCode) {
    mRequestBanner = null;
    recycleCurrentBanner();
    switch(errorCode) {
        case Constants.ERROR_CODE_INTERNAL_ERROR:
            mBannerEventListener.onAdFailed(new AdException(AdException.THIRD_PARTY, "GAM SDK encountered an internal error."));
            break;
        case Constants.ERROR_CODE_INVALID_REQUEST:
            mBannerEventListener.onAdFailed(new AdException(AdException.THIRD_PARTY, "GAM SDK - invalid request error."));
            break;
        case Constants.ERROR_CODE_NETWORK_ERROR:
            mBannerEventListener.onAdFailed(new AdException(AdException.THIRD_PARTY, "GAM SDK - network error."));
            break;
        case Constants.ERROR_CODE_NO_FILL:
            mBannerEventListener.onAdFailed(new AdException(AdException.THIRD_PARTY, "GAM SDK - no fill."));
            break;
        default:
            mBannerEventListener.onAdFailed(new AdException(AdException.THIRD_PARTY, "GAM SDK - failed with errorCode: " + errorCode));
    }
}
Also used : AdException(org.prebid.mobile.rendering.errors.AdException)

Example 37 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class AdViewManagerTest method testAdViewManagerNullParams.

@Test
public void testAdViewManagerNullParams() {
    InterstitialView mockAdView = mock(InterstitialView.class);
    AdViewManager adViewManager = null;
    AdException err = null;
    try {
        adViewManager = new AdViewManager(mContext, null, mockAdView, mMockInterstitialManager);
    } catch (Exception e) {
        err = new AdException(AdException.INTERNAL_ERROR, e.getMessage());
    }
    assertNotNull(err);
    assertNull(adViewManager);
}
Also used : InterstitialView(org.prebid.mobile.rendering.bidding.display.InterstitialView) AdException(org.prebid.mobile.rendering.errors.AdException) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 38 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class AdViewManagerTest method testAdViewManagerNullAdViewListener.

@Test
public void testAdViewManagerNullAdViewListener() {
    InterstitialView mockAdView = mock(InterstitialView.class);
    AdViewManager adViewManager = null;
    AdException err = null;
    try {
        adViewManager = new AdViewManager(mContext, null, mockAdView, mMockInterstitialManager);
    } catch (AdException e) {
        err = e;
    }
    assertNotNull(err);
    assertNull(adViewManager);
    assertEquals(AdException.INTERNAL_ERROR + ": AdViewManagerListener is null", err.getMessage());
}
Also used : InterstitialView(org.prebid.mobile.rendering.bidding.display.InterstitialView) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 39 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class HTMLCreativeTest method webViewFailedToLoadTest.

@Test
public void webViewFailedToLoadTest() throws Exception {
    CreativeResolutionListener mockResolutionListener = mock(CreativeResolutionListener.class);
    mHtmlCreative.setResolutionListener(mockResolutionListener);
    // Resolved
    WhiteBox.field(HTMLCreative.class, "mResolved").set(mHtmlCreative, true);
    mHtmlCreative.webViewFailedToLoad(new AdException("foo", "bar"));
    verify(mockResolutionListener, never()).creativeFailed(any(AdException.class));
    // Not resolved
    WhiteBox.field(HTMLCreative.class, "mResolved").set(mHtmlCreative, false);
    mHtmlCreative.webViewFailedToLoad(new AdException("foo", "bar"));
    verify(mockResolutionListener).creativeFailed(any(AdException.class));
}
Also used : CreativeResolutionListener(org.prebid.mobile.rendering.listeners.CreativeResolutionListener) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 40 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class BannerViewTest method onFailedAndNoWinnerBid_AdRequestStatusIsFinishedNotifyErrorListener.

@Test
public void onFailedAndNoWinnerBid_AdRequestStatusIsFinishedNotifyErrorListener() {
    changePrimaryAdServerRequestStatus(true);
    mBannerView.setBidResponse(null);
    final AdException exception = new AdException(AdException.INTERNAL_ERROR, "Test");
    final BannerEventListener bannerEventListener = getBannerEventListener();
    bannerEventListener.onAdFailed(exception);
    verify(mMockBannerListener, times(1)).onAdFailed(mBannerView, exception);
}
Also used : BannerEventListener(org.prebid.mobile.rendering.bidding.listeners.BannerEventListener) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Aggregations

AdException (org.prebid.mobile.rendering.errors.AdException)54 Test (org.junit.Test)25 InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)7 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)6 AdError (com.google.android.gms.ads.AdError)5 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)5 Bid (org.prebid.mobile.rendering.bidding.data.bid.Bid)4 InterstitialControllerListener (org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener)4 CreativeModel (org.prebid.mobile.rendering.models.CreativeModel)4 InterstitialManager (org.prebid.mobile.rendering.views.interstitial.InterstitialManager)4 Context (android.content.Context)2 Bundle (android.os.Bundle)2 NonNull (androidx.annotation.NonNull)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)2 BannerEventListener (org.prebid.mobile.rendering.bidding.listeners.BannerEventListener)2 InterstitialEventListener (org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener)2 RewardedVideoEventListener (org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener)2 VastExtractorResult (org.prebid.mobile.rendering.models.internal.VastExtractorResult)2