-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/java/io/huangsam/photohaul/migration/TestGoogleDriveMigrator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.huangsam.photohaul.migration; | ||
|
||
import com.google.api.services.drive.Drive; | ||
import com.google.api.services.drive.model.File; | ||
import com.google.api.services.drive.model.FileList; | ||
import io.huangsam.photohaul.TestPathBase; | ||
import io.huangsam.photohaul.traversal.PhotoPathVisitor; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class TestGoogleDriveMigrator extends TestPathBase { | ||
@Mock | ||
Drive driveMock; | ||
|
||
@Mock | ||
Drive.Files filesMock; | ||
|
||
@Mock | ||
Drive.Files.List driveListMock; | ||
|
||
@Mock | ||
FileList fileListMock; | ||
|
||
@Mock | ||
File fileMock; | ||
|
||
@Test | ||
void testMigratePhotos() throws IOException { | ||
when(driveMock.files()).thenReturn(filesMock); | ||
when(filesMock.list()).thenReturn(driveListMock); | ||
when(driveListMock.setQ(any())).thenReturn(driveListMock); | ||
when(driveListMock.execute()).thenReturn(fileListMock); | ||
when(fileListMock.getFiles()).thenReturn(List.of(fileMock)); | ||
|
||
List<String> names = List.of("bauerlite.jpg", "salad.jpg", "foobar.jpg"); | ||
PhotoPathVisitor pathVisitor = visitor(getStaticResources(), names); | ||
Migrator migrator = new GoogleDriveMigrator("Foo", driveMock, new PhotoResolver(List.of())); | ||
migrator.migratePhotos(pathVisitor.getPhotos()); | ||
|
||
assertEquals(3, migrator.getFailureCount()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters