use of org.datatransferproject.types.common.models.videos.VideosContainerResource in project data-transfer-project by google.
the class FacebookVideosExporterTest method testExportVideo.
@Test
public void testExportVideo() throws CopyExceptionWithFailureReason {
ExportResult<VideosContainerResource> result = facebookVideosExporter.export(uuid, new TokensAndUrlAuthData("accessToken", null, null), Optional.of(new ExportInformation(null, null)));
assertEquals(ExportResult.ResultType.END, result.getType());
VideosContainerResource exportedData = result.getExportedData();
assertEquals(1, exportedData.getVideos().size());
assertEquals(new VideoModel(VIDEO_ID + ".mp4", VIDEO_SOURCE, VIDEO_NAME, "video/mp4", VIDEO_ID, null, false), exportedData.getVideos().toArray()[0]);
}
use of org.datatransferproject.types.common.models.videos.VideosContainerResource 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);
}
use of org.datatransferproject.types.common.models.videos.VideosContainerResource in project data-transfer-project by google.
the class BackblazeVideosImporterTest method testEmptyVideos.
@Test
public void testEmptyVideos() throws Exception {
VideosContainerResource data = mock(VideosContainerResource.class);
when(data.getVideos()).thenReturn(new ArrayList<>());
BackblazeVideosImporter sut = new BackblazeVideosImporter(monitor, dataStore, streamProvider, clientFactory);
ImportResult result = sut.importItem(UUID.randomUUID(), executor, authData, data);
assertEquals(ImportResult.OK, result);
}
Aggregations