Search in sources :

Example 1 with OpenMediationBaseAdUnit

use of org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit in project prebid-mobile-android by prebid.

the class MoPubMediationUtilsWithAdUnitsTest method whenOnResponseReceived_UpdateMoPubAndSuccessResult.

@Test
public void whenOnResponseReceived_UpdateMoPubAndSuccessResult() {
    String testConfigId = "configId";
    String responseString = TestResponse.getResponse();
    HashMap<String, String> keywordsMap = TestResponse.getKeywordsMap();
    BidResponse bidResponse = new BidResponse(responseString);
    OnFetchCompleteListener mockListener = mock(OnFetchCompleteListener.class);
    MoPubBannerMediationUtils bannerUtils = mock(MoPubBannerMediationUtils.class);
    OpenMediationBaseAdUnit adUnit = new OpenMediationBaseAdUnit(context, testConfigId, mockAdSize, bannerUtils);
    WhiteBox.setInternalState(adUnit, "mBidLoader", mMockBidLoader);
    adUnit.fetchDemand(mockListener);
    adUnit.onResponseReceived(bidResponse);
    verify(mockListener).onComplete(FetchDemandResult.SUCCESS);
    verify(bannerUtils).setResponseToLocalExtras(bidResponse);
    verify(bannerUtils).handleKeywordsUpdate(keywordsMap);
    assertNotNull(BidResponseCache.getInstance().popBidResponse(bidResponse.getId()));
}
Also used : OnFetchCompleteListener(org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) MoPubBannerMediationUtils(com.mopub.mediation.MoPubBannerMediationUtils) OpenMediationBaseAdUnit(org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit) Test(org.junit.Test)

Aggregations

MoPubBannerMediationUtils (com.mopub.mediation.MoPubBannerMediationUtils)1 Test (org.junit.Test)1 OpenMediationBaseAdUnit (org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit)1 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)1 OnFetchCompleteListener (org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener)1