use of org.datatransferproject.types.common.models.videos.VideoModel in project data-transfer-project by google.
the class BackblazeVideosImporterTest method testImportVideo.
@Test
public void testImportVideo() throws Exception {
String dataId = "dataId";
String title = "title";
String videoUrl = "videoUrl";
String description = "description";
String encodingFormat = "UTF-8";
String albumName = "albumName";
String albumId = "albumId";
String response = "response";
UUID jobId = UUID.randomUUID();
VideoModel videoObject = new VideoModel(title, videoUrl, description, encodingFormat, dataId, albumId, false);
ArrayList<VideoModel> videos = new ArrayList<>();
videos.add(videoObject);
VideosContainerResource data = mock(VideosContainerResource.class);
when(data.getVideos()).thenReturn(videos);
when(executor.getCachedValue(albumId)).thenReturn(albumName);
HttpURLConnection connection = mock(HttpURLConnection.class);
when(connection.getInputStream()).thenReturn(IOUtils.toInputStream("video content", "UTF-8"));
when(streamProvider.getConnection(videoUrl)).thenReturn(connection);
when(client.uploadFile(eq("Video Transfer/dataId.mp4"), any())).thenReturn(response);
when(clientFactory.getOrCreateB2Client(jobId, authData)).thenReturn(client);
BackblazeVideosImporter sut = new BackblazeVideosImporter(monitor, dataStore, streamProvider, clientFactory);
sut.importItem(jobId, executor, authData, data);
ArgumentCaptor<Callable<String>> importCapture = ArgumentCaptor.forClass(Callable.class);
verify(executor, times(1)).executeAndSwallowIOExceptions(eq(dataId), eq(title), importCapture.capture());
String actual = importCapture.getValue().call();
assertEquals(response, actual);
}
Aggregations