Search in sources :

Example 16 with BidResponse

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

the class MoPubMediationUtilsMethodsTest method setResponseToLocalExtrasInBanner_MoPubViewSetsResponseId.

@Test
public void setResponseToLocalExtrasInBanner_MoPubViewSetsResponseId() {
    BidResponse bidResponse = new BidResponse(TestResponse.getResponse());
    bannerUtils.setResponseToLocalExtras(bidResponse);
    HashMap<String, String> responseId = new HashMap<>();
    responseId.put("PREBID_BID_RESPONSE_ID", "id");
    verify(mMoPubView).setLocalExtras(responseId);
}
Also used : HashMap(java.util.HashMap) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Example 17 with BidResponse

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

the class KeywordsSetupTest method setResponseToMoPubLocalExtrasWithMoPubBannerOrInterstitialView_ResponseStoredInLocalExtras.

@Test
public void setResponseToMoPubLocalExtrasWithMoPubBannerOrInterstitialView_ResponseStoredInLocalExtras() {
    MoPubView moPubView = new MoPubView(mActivity);
    MoPubBannerMediationUtils mediationUtils = new MoPubBannerMediationUtils(moPubView);
    BidResponse response = new BidResponse("{\"response\":\"test\", \"id\":\"1234\"}");
    Map<String, Object> expectedLocalExtras = Collections.singletonMap(KEY_BID_RESPONSE, response.getId());
    mediationUtils.setResponseToLocalExtras(response);
    assertEquals(expectedLocalExtras, moPubView.getLocalExtras());
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) MoPubBannerMediationUtils(com.mopub.mediation.MoPubBannerMediationUtils) MoPubView(com.mopub.mobileads.MoPubView) Test(org.junit.Test)

Example 18 with BidResponse

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

the class MoPubMediationUtilsWithAdUnitsTest method whenOnResponseReceived_UpdateHashMapAndBidCache.

@Test
public void whenOnResponseReceived_UpdateHashMapAndBidCache() {
    String responseString = TestResponse.getResponse();
    HashMap<String, String> keywordsMap = TestResponse.getKeywordsMap();
    BidResponse bidResponse = new BidResponse(responseString);
    OnFetchCompleteListener mockListener = mock(OnFetchCompleteListener.class);
    MoPubRewardedVideoMediationUtils mediationUtils = mock(MoPubRewardedVideoMediationUtils.class);
    OpenMediationRewardedVideoAdUnit adUnit = new OpenMediationRewardedVideoAdUnit(context, "mopub", mediationUtils);
    WhiteBox.setInternalState(adUnit, "mBidLoader", mMockBidLoader);
    adUnit.fetchDemand(mockListener);
    adUnit.onResponse(bidResponse);
    verify(mockListener).onComplete(FetchDemandResult.SUCCESS);
    verify(mediationUtils).handleKeywordsUpdate(keywordsMap);
}
Also used : MoPubRewardedVideoMediationUtils(com.mopub.mediation.MoPubRewardedVideoMediationUtils) OnFetchCompleteListener(org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener) OpenMediationRewardedVideoAdUnit(org.prebid.mobile.mopub.mock.OpenMediationRewardedVideoAdUnit) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Example 19 with BidResponse

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

the class BannerViewTest method onError_NullifyWinnerBidAndRequestAdWitNullBid.

@Test
public void onError_NullifyWinnerBidAndRequestAdWitNullBid() {
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final Bid mockBid = mock(Bid.class);
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    mBannerView.setBidResponse(mockBidResponse);
    BidRequesterListener listener = getBidRequesterListener();
    listener.onError(any());
    assertNull(mBannerView.getWinnerBid());
    assertNull(mBannerView.getBidResponse());
    verify(mMockEventHandler, times(1)).requestAdWithBid(eq(null));
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) BidRequesterListener(org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener) Test(org.junit.Test)

Example 20 with BidResponse

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

the class BannerViewTest method loadAd_bidResponseIsInitialized.

@Test
public void loadAd_bidResponseIsInitialized() {
    mBannerView.loadAd();
    BidResponse response = mBannerView.getBidResponse();
    System.out.println(response);
}
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