### Question:
DownloadStrategy { public void inspectNetworkAvailable() throws UnknownHostException { if (isHasAccessNetworkStatePermission == null) { isHasAccessNetworkStatePermission = Util .checkPermission(Manifest.permission.ACCESS_NETWORK_STATE); } if (!isHasAccessNetworkStatePermission) return; if (manager == null) { manager = (ConnectivityManager) OkDownload.with().context() .getSystemService(Context.CONNECTIVITY_SERVICE); } if (!Util.isNetworkAvailable(manager)) { throw new UnknownHostException("network is not available!"); } }  ResumeAvailableResponseCheck resumeAvailableResponseCheck(
            DownloadConnection.Connected connected,
            int blockIndex,
            BreakpointInfo info); int determineBlockCount(@NonNull DownloadTask task, long totalLength); long reuseIdledSameInfoThresholdBytes(); boolean inspectAnotherSameInfo(@NonNull DownloadTask task, @NonNull BreakpointInfo info,
                                          long instanceLength); boolean isUseMultiBlock(final boolean isAcceptRange); void inspectFilenameFromResume(@NonNull String filenameOnStore,
                                          @NonNull DownloadTask task); void validFilenameFromResponse(@Nullable String responseFileName,
                                          @NonNull DownloadTask task,
                                          @NonNull BreakpointInfo info); boolean validFilenameFromStore(@NonNull DownloadTask task); void validInfoOnCompleted(@NonNull DownloadTask task, @NonNull DownloadStore store); @Nullable ResumeFailedCause getPreconditionFailedCause(int responseCode,
                                                                  boolean isAlreadyProceed,
                                                                  @NonNull BreakpointInfo info,
                                                                  @Nullable String responseEtag); boolean isServerCanceled(int responseCode, boolean isAlreadyProceed); void inspectNetworkAvailable(); void inspectNetworkOnWifi(@NonNull DownloadTask task);  }### Answer:
@Test public void inspectNetworkAvailable_noPermission() throws UnknownHostException { final Context context = mock(Context.class); final OkDownload okDownload = OkDownload.with(); doReturn(context).when(okDownload).context(); final ConnectivityManager manager = mock(ConnectivityManager.class); doReturn(manager).when(context).getSystemService(eq(Context.CONNECTIVITY_SERVICE)); final NetworkInfo info = mock(NetworkInfo.class); doReturn(info).when(manager).getActiveNetworkInfo(); doReturn(true).when(info).isConnected(); strategy.isHasAccessNetworkStatePermission = false; strategy.inspectNetworkAvailable(); }
@Test public void inspectNetworkAvailable_withPermission() throws UnknownHostException { final Context context = mock(Context.class); final OkDownload okDownload = OkDownload.with(); doReturn(context).when(okDownload).context(); final ConnectivityManager manager = mock(ConnectivityManager.class); doReturn(manager).when(context).getSystemService(eq(Context.CONNECTIVITY_SERVICE)); final NetworkInfo info = mock(NetworkInfo.class); doReturn(info).when(manager).getActiveNetworkInfo(); doReturn(true).when(info).isConnected(); strategy.isHasAccessNetworkStatePermission = true; strategy.inspectNetworkAvailable(); doReturn(null).when(context).getSystemService(eq(Context.CONNECTIVITY_SERVICE)); strategy.inspectNetworkAvailable(); doReturn(manager).when(context).getSystemService(eq(Context.CONNECTIVITY_SERVICE)); doReturn(null).when(manager).getActiveNetworkInfo(); thrown.expect(UnknownHostException.class); thrown.expectMessage("network is not available!"); strategy.inspectNetworkAvailable(); doReturn(false).when(info).isConnected(); thrown.expect(UnknownHostException.class); thrown.expectMessage("network is not available!"); strategy.inspectNetworkAvailable(); }