@Test public void onAdSuccess_noCEFound_shouldLoadFailUrl() { AdResponse testResponse = new AdResponse.Builder() .setAdType(AdType.CUSTOM) .setCustomEventClassName("doesn't_Exist") .setFailoverUrl("fail.url") .build(); MoPubRewardedVideoManager.loadVideo("testAdUnit"); assertThat(request.getUrl()).contains("testAdUnit"); requestListener.onSuccess(testResponse); assertThat(request.getUrl()).isEqualTo("fail.url"); requestListener.onErrorResponse(new VolleyError("reset")); }
public static void loadVideo(@NonNull String adUnitId, @Nullable final MediationSettings... mediationSettings) { if (sInstance == null) { logErrorNotInitialized(); return; } final Set<MediationSettings> newInstanceMediationSettings = new HashSet<MediationSettings>(); MoPubCollections.addAllNonNull(newInstanceMediationSettings, mediationSettings); sInstance.mInstanceMediationSettings.put(adUnitId, newInstanceMediationSettings); final AdUrlGenerator urlGenerator = new WebViewAdUrlGenerator(sInstance.mContext, false); final String adUrlString = urlGenerator.withAdUnitId(adUnitId) .withLocation( LocationService.getLastKnownLocation( sInstance.mContext, MoPub.getLocationPrecision(), MoPub.getLocationAwareness() ) ) .generateUrlString(Constants.HOST); loadVideo(adUnitId, adUrlString); }
MoPubRewardedVideoManager { public static void loadVideo(@NonNull String adUnitId, @Nullable final MediationSettings... mediationSettings) { if (sInstance == null) { logErrorNotInitialized(); return; } final Set<MediationSettings> newInstanceMediationSettings = new HashSet<MediationSettings>(); MoPubCollections.addAllNonNull(newInstanceMediationSettings, mediationSettings); sInstance.mInstanceMediationSettings.put(adUnitId, newInstanceMediationSettings); final AdUrlGenerator urlGenerator = new WebViewAdUrlGenerator(sInstance.mContext, false); final String adUrlString = urlGenerator.withAdUnitId(adUnitId) .withLocation( LocationService.getLastKnownLocation( sInstance.mContext, MoPub.getLocationPrecision(), MoPub.getLocationAwareness() ) ) .generateUrlString(Constants.HOST); loadVideo(adUnitId, adUrlString); } }
MoPubRewardedVideoManager { public static void loadVideo(@NonNull String adUnitId, @Nullable final MediationSettings... mediationSettings) { if (sInstance == null) { logErrorNotInitialized(); return; } final Set<MediationSettings> newInstanceMediationSettings = new HashSet<MediationSettings>(); MoPubCollections.addAllNonNull(newInstanceMediationSettings, mediationSettings); sInstance.mInstanceMediationSettings.put(adUnitId, newInstanceMediationSettings); final AdUrlGenerator urlGenerator = new WebViewAdUrlGenerator(sInstance.mContext, false); final String adUrlString = urlGenerator.withAdUnitId(adUnitId) .withLocation( LocationService.getLastKnownLocation( sInstance.mContext, MoPub.getLocationPrecision(), MoPub.getLocationAwareness() ) ) .generateUrlString(Constants.HOST); loadVideo(adUnitId, adUrlString); } private  MoPubRewardedVideoManager(@NonNull Activity mainActivity, MediationSettings... mediationSettings); }
MoPubRewardedVideoManager { public static void loadVideo(@NonNull String adUnitId, @Nullable final MediationSettings... mediationSettings) { if (sInstance == null) { logErrorNotInitialized(); return; } final Set<MediationSettings> newInstanceMediationSettings = new HashSet<MediationSettings>(); MoPubCollections.addAllNonNull(newInstanceMediationSettings, mediationSettings); sInstance.mInstanceMediationSettings.put(adUnitId, newInstanceMediationSettings); final AdUrlGenerator urlGenerator = new WebViewAdUrlGenerator(sInstance.mContext, false); final String adUrlString = urlGenerator.withAdUnitId(adUnitId) .withLocation( LocationService.getLastKnownLocation( sInstance.mContext, MoPub.getLocationPrecision(), MoPub.getLocationAwareness() ) ) .generateUrlString(Constants.HOST); loadVideo(adUnitId, adUrlString); } private  MoPubRewardedVideoManager(@NonNull Activity mainActivity, MediationSettings... mediationSettings); static synchronized void init(@NonNull Activity mainActivity, MediationSettings... mediationSettings); static void updateActivity(@NonNull Activity activity); @Nullable static T getGlobalMediationSettings(@NonNull final Class<T> clazz); @Nullable static T getInstanceMediationSettings(
            @NonNull final Class<T> clazz, @NonNull final String adUnitId); static void setVideoListener(@Nullable MoPubRewardedVideoListener listener); static void loadVideo(@NonNull String adUnitId, @Nullable final MediationSettings... mediationSettings); static boolean hasVideo(@NonNull String adUnitId); static void showVideo(@NonNull String adUnitId); static void onRewardedVideoLoadSuccess(@NonNull final Class<T> customEventClass, @NonNull final String thirdPartyId); static void onRewardedVideoLoadFailure(@NonNull final Class<T> customEventClass, final String thirdPartyId, final MoPubErrorCode errorCode); static void onRewardedVideoStarted(@NonNull final Class<T> customEventClass, final String thirdPartyId); static void onRewardedVideoPlaybackError(@NonNull final Class<T> customEventClass, final String thirdPartyId, final MoPubErrorCode errorCode); static void onRewardedVideoClicked(@NonNull final Class<T> customEventClass, final String thirdPartyId); static void onRewardedVideoClosed(@NonNull final Class<T> customEventClass, final String thirdPartyId); static void onRewardedVideoCompleted(@NonNull final Class<T> customEventClass, final String thirdPartyId, @NonNull final MoPubReward moPubReward); }
MoPubRewardedVideoManager { public static void loadVideo(@NonNull String adUnitId, @Nullable final MediationSettings... mediationSettings) { if (sInstance == null) { logErrorNotInitialized(); return; } final Set<MediationSettings> newInstanceMediationSettings = new HashSet<MediationSettings>(); MoPubCollections.addAllNonNull(newInstanceMediationSettings, mediationSettings); sInstance.mInstanceMediationSettings.put(adUnitId, newInstanceMediationSettings); final AdUrlGenerator urlGenerator = new WebViewAdUrlGenerator(sInstance.mContext, false); final String adUrlString = urlGenerator.withAdUnitId(adUnitId) .withLocation( LocationService.getLastKnownLocation( sInstance.mContext, MoPub.getLocationPrecision(), MoPub.getLocationAwareness() ) ) .generateUrlString(Constants.HOST); loadVideo(adUnitId, adUrlString); } private  MoPubRewardedVideoManager(@NonNull Activity mainActivity, MediationSettings... mediationSettings); static synchronized void init(@NonNull Activity mainActivity, MediationSettings... mediationSettings); static void updateActivity(@NonNull Activity activity); @Nullable static T getGlobalMediationSettings(@NonNull final Class<T> clazz); @Nullable static T getInstanceMediationSettings(
            @NonNull final Class<T> clazz, @NonNull final String adUnitId); static void setVideoListener(@Nullable MoPubRewardedVideoListener listener); static void loadVideo(@NonNull String adUnitId, @Nullable final MediationSettings... mediationSettings); static boolean hasVideo(@NonNull String adUnitId); static void showVideo(@NonNull String adUnitId); static void onRewardedVideoLoadSuccess(@NonNull final Class<T> customEventClass, @NonNull final String thirdPartyId); static void onRewardedVideoLoadFailure(@NonNull final Class<T> customEventClass, final String thirdPartyId, final MoPubErrorCode errorCode); static void onRewardedVideoStarted(@NonNull final Class<T> customEventClass, final String thirdPartyId); static void onRewardedVideoPlaybackError(@NonNull final Class<T> customEventClass, final String thirdPartyId, final MoPubErrorCode errorCode); static void onRewardedVideoClicked(@NonNull final Class<T> customEventClass, final String thirdPartyId); static void onRewardedVideoClosed(@NonNull final Class<T> customEventClass, final String thirdPartyId); static void onRewardedVideoCompleted(@NonNull final Class<T> customEventClass, final String thirdPartyId, @NonNull final MoPubReward moPubReward);  }