@Test(expected = NullPointerException.class) public void uploadVideo_FileIsNull_ThrowsNullPointerException() { ServerWrapper server = new ServerWrapper(null, null); server.downloadVideo(null); }
public boolean downloadVideo(String downloadId) { boolean successful = true; HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("download") .addQueryParameter("download_id", downloadId) .build(); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); byte[] video = response.body().bytes(); this.filesystemWrapper.saveDownloadedVideo(video); } catch (IOException e) { e.printStackTrace(); successful = false; } catch (IllegalStateException e) { e.printStackTrace(); successful = false; } return successful; }
ServerWrapper { public boolean downloadVideo(String downloadId) { boolean successful = true; HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("download") .addQueryParameter("download_id", downloadId) .build(); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); byte[] video = response.body().bytes(); this.filesystemWrapper.saveDownloadedVideo(video); } catch (IOException e) { e.printStackTrace(); successful = false; } catch (IllegalStateException e) { e.printStackTrace(); successful = false; } return successful; } }
ServerWrapper { public boolean downloadVideo(String downloadId) { boolean successful = true; HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("download") .addQueryParameter("download_id", downloadId) .build(); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); byte[] video = response.body().bytes(); this.filesystemWrapper.saveDownloadedVideo(video); } catch (IOException e) { e.printStackTrace(); successful = false; } catch (IllegalStateException e) { e.printStackTrace(); successful = false; } return successful; } @Inject  ServerWrapper(OkHttpClient okHttpClient, FileSystemWrapper filesystemWrapper); }
ServerWrapper { public boolean downloadVideo(String downloadId) { boolean successful = true; HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("download") .addQueryParameter("download_id", downloadId) .build(); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); byte[] video = response.body().bytes(); this.filesystemWrapper.saveDownloadedVideo(video); } catch (IOException e) { e.printStackTrace(); successful = false; } catch (IllegalStateException e) { e.printStackTrace(); successful = false; } return successful; } @Inject  ServerWrapper(OkHttpClient okHttpClient, FileSystemWrapper filesystemWrapper); Boolean ping(); String uploadVideo(File video); String downloadYouTubeVideo(String youtubeUrl); String processVideo(String videoId, SettingsProvider settingsProvider); boolean downloadVideo(String downloadId); }
ServerWrapper { public boolean downloadVideo(String downloadId) { boolean successful = true; HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("download") .addQueryParameter("download_id", downloadId) .build(); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); byte[] video = response.body().bytes(); this.filesystemWrapper.saveDownloadedVideo(video); } catch (IOException e) { e.printStackTrace(); successful = false; } catch (IllegalStateException e) { e.printStackTrace(); successful = false; } return successful; } @Inject  ServerWrapper(OkHttpClient okHttpClient, FileSystemWrapper filesystemWrapper); Boolean ping(); String uploadVideo(File video); String downloadYouTubeVideo(String youtubeUrl); String processVideo(String videoId, SettingsProvider settingsProvider); boolean downloadVideo(String downloadId); public boolean HasError; }