@Test public void processVideo_NoAdvancedOptions_ServerCallAsExpectedAndDownloadIdReturned() { String ExpectedDownloadId = "download_id"; String SoundedSpeed = "1"; String SilentSpeed = "2"; String SilenceThreshold = "3"; String FrameMargin = "4"; MockInterceptor okHttpMockInterceptor = new MockInterceptor(); okHttpMockInterceptor.addRule() .get() .url(new ProcessUrlBuilder() .withHost("jumpcutter.letum.ch") .withSoundedSpeed(SoundedSpeed) .withSilentSpeed(SilentSpeed) .withSilentThreshold(SilenceThreshold) .withFrameMargin(FrameMargin) .build() .toString()) .respond(ExpectedDownloadId); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(okHttpMockInterceptor) .build(); SettingsProvider settingsProviderMock = Mockito.mock(SettingsProvider.class); when(settingsProviderMock.getSoundSpeed()) .thenReturn(SoundedSpeed); when(settingsProviderMock.getSilenceSpeed()) .thenReturn(SilentSpeed); when(settingsProviderMock.getSilenceThreshold()) .thenReturn(SilenceThreshold); when(settingsProviderMock.getFrameMargin()) .thenReturn(FrameMargin); when(settingsProviderMock.getAdvancedOptionsSwitchEnabled()) .thenReturn(false); ServerWrapper server = new ServerWrapper(okHttpClient, null); String downloadId = server.processVideo(null, settingsProviderMock); Assert.assertEquals(ExpectedDownloadId, downloadId); }
public String processVideo(String videoId, SettingsProvider settingsProvider) { ProcessUrlBuilder urlBuilder = new ProcessUrlBuilder() .withHost(this.Host) .withScheme(this.Scheme) .withVideoId(videoId) .withSoundedSpeed(settingsProvider.getSoundSpeed()) .withSilentSpeed(settingsProvider.getSilenceSpeed()) .withSilentThreshold(settingsProvider.getSilenceThreshold()) .withFrameMargin(settingsProvider.getFrameMargin()); if (settingsProvider.getAdvancedOptionsSwitchEnabled()) { urlBuilder .withSampleRate(settingsProvider.getSampleRate()) .withFrameRate(settingsProvider.getFrameRate()) .withFrameQuality(settingsProvider.getFrameQuality()); } HttpUrl url = urlBuilder.build(); Request request = new Request.Builder() .url(url) .get() .build(); return this.getStringResponseFromServer(request); }
ServerWrapper { public String processVideo(String videoId, SettingsProvider settingsProvider) { ProcessUrlBuilder urlBuilder = new ProcessUrlBuilder() .withHost(this.Host) .withScheme(this.Scheme) .withVideoId(videoId) .withSoundedSpeed(settingsProvider.getSoundSpeed()) .withSilentSpeed(settingsProvider.getSilenceSpeed()) .withSilentThreshold(settingsProvider.getSilenceThreshold()) .withFrameMargin(settingsProvider.getFrameMargin()); if (settingsProvider.getAdvancedOptionsSwitchEnabled()) { urlBuilder .withSampleRate(settingsProvider.getSampleRate()) .withFrameRate(settingsProvider.getFrameRate()) .withFrameQuality(settingsProvider.getFrameQuality()); } HttpUrl url = urlBuilder.build(); Request request = new Request.Builder() .url(url) .get() .build(); return this.getStringResponseFromServer(request); } }
ServerWrapper { public String processVideo(String videoId, SettingsProvider settingsProvider) { ProcessUrlBuilder urlBuilder = new ProcessUrlBuilder() .withHost(this.Host) .withScheme(this.Scheme) .withVideoId(videoId) .withSoundedSpeed(settingsProvider.getSoundSpeed()) .withSilentSpeed(settingsProvider.getSilenceSpeed()) .withSilentThreshold(settingsProvider.getSilenceThreshold()) .withFrameMargin(settingsProvider.getFrameMargin()); if (settingsProvider.getAdvancedOptionsSwitchEnabled()) { urlBuilder .withSampleRate(settingsProvider.getSampleRate()) .withFrameRate(settingsProvider.getFrameRate()) .withFrameQuality(settingsProvider.getFrameQuality()); } HttpUrl url = urlBuilder.build(); Request request = new Request.Builder() .url(url) .get() .build(); return this.getStringResponseFromServer(request); } @Inject  ServerWrapper(OkHttpClient okHttpClient, FileSystemWrapper filesystemWrapper); }
ServerWrapper { public String processVideo(String videoId, SettingsProvider settingsProvider) { ProcessUrlBuilder urlBuilder = new ProcessUrlBuilder() .withHost(this.Host) .withScheme(this.Scheme) .withVideoId(videoId) .withSoundedSpeed(settingsProvider.getSoundSpeed()) .withSilentSpeed(settingsProvider.getSilenceSpeed()) .withSilentThreshold(settingsProvider.getSilenceThreshold()) .withFrameMargin(settingsProvider.getFrameMargin()); if (settingsProvider.getAdvancedOptionsSwitchEnabled()) { urlBuilder .withSampleRate(settingsProvider.getSampleRate()) .withFrameRate(settingsProvider.getFrameRate()) .withFrameQuality(settingsProvider.getFrameQuality()); } HttpUrl url = urlBuilder.build(); Request request = new Request.Builder() .url(url) .get() .build(); return this.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 processVideo(String videoId, SettingsProvider settingsProvider) { ProcessUrlBuilder urlBuilder = new ProcessUrlBuilder() .withHost(this.Host) .withScheme(this.Scheme) .withVideoId(videoId) .withSoundedSpeed(settingsProvider.getSoundSpeed()) .withSilentSpeed(settingsProvider.getSilenceSpeed()) .withSilentThreshold(settingsProvider.getSilenceThreshold()) .withFrameMargin(settingsProvider.getFrameMargin()); if (settingsProvider.getAdvancedOptionsSwitchEnabled()) { urlBuilder .withSampleRate(settingsProvider.getSampleRate()) .withFrameRate(settingsProvider.getFrameRate()) .withFrameQuality(settingsProvider.getFrameQuality()); } HttpUrl url = urlBuilder.build(); Request request = new Request.Builder() .url(url) .get() .build(); return this.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; }