Search in sources :

Example 26 with BidResponse

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

the class TransactionManagerTest method whenFetchBidTransaction_AttemptToMakeModels.

@Test
public void whenFetchBidTransaction_AttemptToMakeModels() {
    BidResponse mockBidResponse = mock(BidResponse.class);
    when(mockBidResponse.getWinningBid()).thenReturn(mock(Bid.class));
    when(mockBidResponse.getWinningBid().getAdm()).thenReturn("adm");
    mTransactionManager.fetchBidTransaction(mock(AdConfiguration.class), mockBidResponse);
    verify(mMockListener).onFetchingFailed(any(AdException.class));
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 27 with BidResponse

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

the class DisplayViewTest method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(DisplayViewTest.this);
    mContext = Robolectric.buildActivity(Activity.class).create().get();
    mAdUnitConfiguration = new AdConfiguration();
    mAdUnitConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    BidResponse mockResponse = mock(BidResponse.class);
    Bid mockBid = mock(Bid.class);
    when(mockBid.getAdm()).thenReturn("adm");
    when(mockResponse.getWinningBid()).thenReturn(mockBid);
    mDisplayView = new DisplayView(mContext, mMockDisplayViewListener, mAdUnitConfiguration, mockResponse);
    reset(mMockDisplayViewListener);
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Activity(android.app.Activity) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) Before(org.junit.Before)

Example 28 with BidResponse

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

the class InterstitialControllerTest method loadAd_ExecuteInterstitialViewLoadAd.

@Test
public void loadAd_ExecuteInterstitialViewLoadAd() {
    final AdConfiguration mockAdUnitConfiguration = mock(AdConfiguration.class);
    final BidResponse mockBidResponse = mock(BidResponse.class);
    mInterstitialController.loadAd(mockAdUnitConfiguration, mockBidResponse);
    verify(mMockInterstitialView, times(1)).loadAd(eq(mockAdUnitConfiguration), eq(mockBidResponse));
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Example 29 with BidResponse

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

the class BidResponseCacheTest method whenPutBidResponse_ShouldPopulateMap.

@Test
public void whenPutBidResponse_ShouldPopulateMap() {
    BidResponse mockResponse = mock(BidResponse.class);
    when(mockResponse.getId()).thenReturn("id");
    BidResponseCache.getInstance().putBidResponse(mockResponse);
    final Map<String, BidResponse> cachedResponses = BidResponseCache.getCachedBidResponses();
    assertEquals(1, cachedResponses.size());
    assertEquals(mockResponse, cachedResponses.get("id"));
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Example 30 with BidResponse

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

the class BidResponseCacheTest method whenPutBidResponse_WithStaleResponsePresent_RemoveStaleResponse.

@Test
public void whenPutBidResponse_WithStaleResponsePresent_RemoveStaleResponse() {
    final Map<String, BidResponse> cachedTransactions = BidResponseCache.getCachedBidResponses();
    for (int i = 0; i < 5; i++) {
        BidResponse mockResponse = mock(BidResponse.class);
        when(mockResponse.getId()).thenReturn("id" + Math.random());
        when(mockResponse.getCreationTime()).thenReturn(System.currentTimeMillis() - 61 * 1000);
        cachedTransactions.put("id" + Math.random(), mockResponse);
    }
    assertEquals(5, cachedTransactions.size());
    BidResponse mockResponse = mock(BidResponse.class);
    when(mockResponse.getId()).thenReturn("id" + System.currentTimeMillis());
    when(mockResponse.getCreationTime()).thenReturn(System.currentTimeMillis());
    BidResponseCache.getInstance().putBidResponse(mockResponse);
    assertEquals(1, 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