MoPubNative { void requestNativeAd(@Nullable final String endpointUrl) { final Context context = getContextOrDestroy(); if (context == null) { return; } if (endpointUrl == null) { mMoPubNativeNetworkListener.onNativeFail(INVALID_REQUEST_URL); return; } final HttpGet httpGet; try { httpGet = HttpClient.initializeHttpGet(endpointUrl, context); } catch (IllegalArgumentException e) { mMoPubNativeNetworkListener.onNativeFail(INVALID_REQUEST_URL); return; } downloadJson(httpGet); } @Deprecated  MoPubNative(@NonNull final Context context,
            @NonNull final String adUnitId,
            @NonNull final MoPubNativeListener moPubNativeListener);  MoPubNative(@NonNull final Context context,
                @NonNull final String adUnitId,
                @NonNull final MoPubNativeNetworkListener moPubNativeNetworkListener); void setNativeEventListener(@Nullable final MoPubNativeEventListener nativeEventListener); void destroy(); void setLocalExtras(@Nullable final Map<String, Object> localExtras); void makeRequest(); void makeRequest(@Nullable final RequestParameters requestParameters); void makeRequest(@Nullable final RequestParameters requestParameters,
            @Nullable Integer sequenceNumber);  }
@Test public void requestNativeAd_withValidUrl_shouldStartDownloadTaskWithUrl() { Robolectric.getUiThreadScheduler().pause(); Robolectric.addPendingHttpResponse(200, "body"); subject.requestNativeAd("http: verify(mockNetworkListener, never()).onNativeFail(any(NativeErrorCode.class)); assertThat(wasDownloadTaskExecuted()).isTrue(); List<?> latestParams = ShadowAsyncTasks.getLatestParams(); assertThat(latestParams).hasSize(1); HttpGet httpGet = (HttpGet) latestParams.get(0); assertThat(httpGet.getURI().toString()).isEqualTo("http: }
@Test public void requestNativeAd_withInvalidUrl_shouldFireNativeFailAndNotStartAsyncTask() { Robolectric.getUiThreadScheduler().pause(); subject.requestNativeAd(" verify(mockNetworkListener).onNativeFail(any(NativeErrorCode.class)); assertThat(wasDownloadTaskExecuted()).isFalse(); }
@Test public void requestNativeAd_withNullUrl_shouldFireNativeFailAndNotStartAsyncTask() { Robolectric.getUiThreadScheduler().pause(); subject.requestNativeAd(null); verify(mockNetworkListener).onNativeFail(any(NativeErrorCode.class)); assertThat(wasDownloadTaskExecuted()).isFalse(); }