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()));
}
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);
}
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);
}
Aggregations