Search in sources :

Example 1 with OnFetchCompleteListener

use of org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener 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)

Example 2 with OnFetchCompleteListener

use of org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener in project prebid-mobile-android by prebid.

the class MediationBaseAdUnitTest method whenOnErrorReceived_PassErrorMessage.

@Test
public void whenOnErrorReceived_PassErrorMessage() {
    PrebidRenderingSettings.setAccountId("id");
    OnFetchCompleteListener mockListener = mock(OnFetchCompleteListener.class);
    AdException adException = new AdException(AdException.INTERNAL_ERROR, "");
    mBaseAdUnit.fetchDemand(mockListener);
    mBaseAdUnit.onErrorReceived(adException);
    verify(mockListener).onComplete(FetchDemandResult.SERVER_ERROR);
}
Also used : OnFetchCompleteListener(org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 3 with OnFetchCompleteListener

use of org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener 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)

Aggregations

Test (org.junit.Test)3 OnFetchCompleteListener (org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener)3 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)2 MoPubBannerMediationUtils (com.mopub.mediation.MoPubBannerMediationUtils)1 MoPubRewardedVideoMediationUtils (com.mopub.mediation.MoPubRewardedVideoMediationUtils)1 OpenMediationBaseAdUnit (org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit)1 OpenMediationRewardedVideoAdUnit (org.prebid.mobile.mopub.mock.OpenMediationRewardedVideoAdUnit)1 AdException (org.prebid.mobile.rendering.errors.AdException)1