Search in sources :

Example 6 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class CreativeModelMakerBidsTest method whenMakeModelsAndBidResponseWithError_CallErrorListener.

@Test
public void whenMakeModelsAndBidResponseWithError_CallErrorListener() {
    BidResponse mockResponse = mock(BidResponse.class);
    when(mockResponse.hasParseError()).thenReturn(true);
    mModelMakerBids.makeModels(null, mockResponse);
    verify(mMockLoadListener).onFailedToLoadAd(any(AdException.class), any());
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 7 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class VideoViewTest method loadAd_LoadBidTransaction.

@Test
public void loadAd_LoadBidTransaction() {
    final AdConfiguration adUnitConfiguration = new AdConfiguration();
    final BidResponse bidResponse = new BidResponse("");
    mVideoView.loadAd(adUnitConfiguration, bidResponse);
    verify(mMockAdViewManager).loadBidTransaction(adUnitConfiguration, bidResponse);
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Example 8 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class RewardedAdUnitTest method onFailedAndWithWinnerBid_ExecuteInterstitialControllerLoadAd.

@Test
public void onFailedAndWithWinnerBid_ExecuteInterstitialControllerLoadAd() throws IllegalAccessException {
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final InterstitialController mockInterstitialController = mock(InterstitialController.class);
    final Bid mockBid = mock(Bid.class);
    final RewardedVideoEventListener spyEventListener = spy(getEventListener());
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    WhiteBox.setInternalState(mRewardedAdUnit, "mBidResponse", mockBidResponse);
    WhiteBox.setInternalState(mRewardedAdUnit, "mInterstitialController", mockInterstitialController);
    spyEventListener.onAdFailed(new AdException(AdException.INTERNAL_ERROR, "Test"));
    verify(spyEventListener, times(1)).onPrebidSdkWin();
    verify(mockInterstitialController, times(1)).loadAd(any(), any());
}
Also used : InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) RewardedVideoEventListener(org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 9 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class BidResponseCacheTest method whenPopBidResponse_ShouldReturnBidResponse_ShouldRemoveMappings.

@Test
public void whenPopBidResponse_ShouldReturnBidResponse_ShouldRemoveMappings() {
    BidResponse mockResponse = mock(BidResponse.class);
    when(mockResponse.getId()).thenReturn("id");
    long time = System.currentTimeMillis();
    when(mockResponse.getCreationTime()).thenReturn(time);
    BidResponseCache.getInstance().putBidResponse(mockResponse);
    final BidResponse result = BidResponseCache.getInstance().popBidResponse("id");
    assertTrue(BidResponseCache.getCachedBidResponses().isEmpty());
    assertEquals(mockResponse, result);
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Example 10 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class BidResponseCacheTest method whenPutBidResponse_WithMaxSizeReached_ShouldIgnoreStoreRequest.

@Test
public void whenPutBidResponse_WithMaxSizeReached_ShouldIgnoreStoreRequest() {
    for (int i = 0; i < BidResponseCache.MAX_SIZE; i++) {
        BidResponse mockResponse = mock(BidResponse.class);
        when(mockResponse.getId()).thenReturn("id" + Math.random());
        when(mockResponse.getCreationTime()).thenReturn(System.currentTimeMillis());
        BidResponseCache.getInstance().putBidResponse(mockResponse);
    }
    final Map<String, BidResponse> cachedTransactions = BidResponseCache.getCachedBidResponses();
    assertEquals(BidResponseCache.MAX_SIZE, cachedTransactions.size());
    BidResponse mockResponse = mock(BidResponse.class);
    when(mockResponse.getId()).thenReturn("id" + System.currentTimeMillis());
    BidResponseCache.getInstance().putBidResponse(mockResponse);
    assertEquals(BidResponseCache.MAX_SIZE, cachedTransactions.size());
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Aggregations

BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)30 Test (org.junit.Test)26 Bid (org.prebid.mobile.rendering.bidding.data.bid.Bid)12 AdException (org.prebid.mobile.rendering.errors.AdException)7 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)7 BidRequesterListener (org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener)6 MoPubBannerMediationUtils (com.mopub.mediation.MoPubBannerMediationUtils)2 HashMap (java.util.HashMap)2 InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)2 BannerEventListener (org.prebid.mobile.rendering.bidding.listeners.BannerEventListener)2 OnFetchCompleteListener (org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener)2 Activity (android.app.Activity)1 Nullable (androidx.annotation.Nullable)1 AdError (com.google.android.gms.ads.AdError)1 MoPubRewardedVideoMediationUtils (com.mopub.mediation.MoPubRewardedVideoMediationUtils)1 MoPubView (com.mopub.mobileads.MoPubView)1 Before (org.junit.Before)1 OpenMediationBaseAdUnit (org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit)1 OpenMediationRewardedVideoAdUnit (org.prebid.mobile.mopub.mock.OpenMediationRewardedVideoAdUnit)1 DisplayView (org.prebid.mobile.rendering.bidding.display.DisplayView)1