@Test public void ping_ServerOnline_ReturnsTrue() { MockInterceptor okHttpMockInterceptor = new MockInterceptor(); okHttpMockInterceptor.addRule() .get() .url("https: .respond("ok"); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(okHttpMockInterceptor) .build(); ServerWrapper server = new ServerWrapper(okHttpClient, null); Boolean response = server.ping(); Assert.assertEquals(true, response); }
public Boolean ping() { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .build(); System.out.println("ServerWrapper: ping() " + url); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); System.out.print(response.body()); return response.isSuccessful(); } catch (IOException e) { this.HasError = true; return false; } catch (IllegalStateException e) { this.HasError = true; return false; } }
ServerWrapper { public Boolean ping() { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .build(); System.out.println("ServerWrapper: ping() " + url); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); System.out.print(response.body()); return response.isSuccessful(); } catch (IOException e) { this.HasError = true; return false; } catch (IllegalStateException e) { this.HasError = true; return false; } } }
ServerWrapper { public Boolean ping() { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .build(); System.out.println("ServerWrapper: ping() " + url); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); System.out.print(response.body()); return response.isSuccessful(); } catch (IOException e) { this.HasError = true; return false; } catch (IllegalStateException e) { this.HasError = true; return false; } } @Inject  ServerWrapper(OkHttpClient okHttpClient, FileSystemWrapper filesystemWrapper); }
ServerWrapper { public Boolean ping() { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .build(); System.out.println("ServerWrapper: ping() " + url); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); System.out.print(response.body()); return response.isSuccessful(); } catch (IOException e) { this.HasError = true; return false; } catch (IllegalStateException e) { this.HasError = true; return false; } } @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 ping() { HttpUrl url = new HttpUrl.Builder() .scheme(this.Scheme) .host(this.Host) .build(); System.out.println("ServerWrapper: ping() " + url); Request request = new Request.Builder() .url(url) .get() .build(); try { Response response = this.okHttpClient.newCall(request).execute(); System.out.print(response.body()); return response.isSuccessful(); } catch (IOException e) { this.HasError = true; return false; } catch (IllegalStateException e) { this.HasError = true; return false; } } @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; }