@Test public void downloadYouTubeVideo_VideoUploadFailed_ReturnsNull() { MockInterceptor okHttpMockInterceptor = new MockInterceptor(); okHttpMockInterceptor.addRule() .get() .urlStarts("https: .answer(request -> new Response.Builder().code(404)); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(okHttpMockInterceptor) .build(); ServerWrapper server = new ServerWrapper(okHttpClient, null); String videoId = server.downloadYouTubeVideo(null); Assert.assertEquals(null, videoId); }
public String downloadYouTubeVideo(String youtubeUrl) { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("youtube") .addQueryParameter("url", youtubeUrl) .build(); Request request = new Request.Builder() .url(url) .get() .build(); return getStringResponseFromServer(request); }
ServerWrapper { public String downloadYouTubeVideo(String youtubeUrl) { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("youtube") .addQueryParameter("url", youtubeUrl) .build(); Request request = new Request.Builder() .url(url) .get() .build(); return getStringResponseFromServer(request); } }
ServerWrapper { public String downloadYouTubeVideo(String youtubeUrl) { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("youtube") .addQueryParameter("url", youtubeUrl) .build(); Request request = new Request.Builder() .url(url) .get() .build(); return getStringResponseFromServer(request); } @Inject  ServerWrapper(OkHttpClient okHttpClient, FileSystemWrapper filesystemWrapper); }
ServerWrapper { public String downloadYouTubeVideo(String youtubeUrl) { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("youtube") .addQueryParameter("url", youtubeUrl) .build(); Request request = new Request.Builder() .url(url) .get() .build(); return getStringResponseFromServer(request); } @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 String downloadYouTubeVideo(String youtubeUrl) { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .addPathSegment("youtube") .addQueryParameter("url", youtubeUrl) .build(); Request request = new Request.Builder() .url(url) .get() .build(); return getStringResponseFromServer(request); } @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; }