Search in sources :

Example 1 with LocalJobStore

use of org.datatransferproject.cloud.local.LocalJobStore in project data-transfer-project by google.

the class JobPollingServiceTest method setUp.

@Before
public void setUp() {
    store = new LocalJobStore();
    PublicKeySerializer serializer = new PublicKeySerializer() {

        @Override
        public boolean canHandle(String scheme) {
            return true;
        }

        @Override
        public String serialize(byte[] encodedPublicKey) throws SecurityException {
            return "key";
        }
    };
    Scheduler scheduler = Scheduler.newFixedDelaySchedule(0, 20, TimeUnit.SECONDS);
    Monitor monitor = new Monitor() {
    };
    ExtensionContext extensionContext = mock(ExtensionContext.class);
    when(extensionContext.getSetting("credTimeoutSeconds", 300)).thenReturn(300);
    jobPollingService = new JobPollingService(store, asymmetricKeyGenerator, serializer, scheduler, monitor, extensionContext);
}
Also used : LocalJobStore(org.datatransferproject.cloud.local.LocalJobStore) Monitor(org.datatransferproject.api.launcher.Monitor) PublicKeySerializer(org.datatransferproject.spi.transfer.security.PublicKeySerializer) Scheduler(com.google.common.util.concurrent.AbstractScheduledService.Scheduler) ExtensionContext(org.datatransferproject.api.launcher.ExtensionContext) Before(org.junit.Before)

Example 2 with LocalJobStore

use of org.datatransferproject.cloud.local.LocalJobStore in project data-transfer-project by google.

the class GooglePhotosImporterTest method setUp.

@Before
public void setUp() throws IOException, InvalidTokenException, PermissionDeniedException {
    googlePhotosInterface = Mockito.mock(GooglePhotosInterface.class);
    monitor = Mockito.mock(Monitor.class);
    executor = new InMemoryIdempotentImportExecutor(monitor);
    Mockito.when(googlePhotosInterface.makePostRequest(anyString(), any(), any(), eq(NewMediaItemResult.class))).thenReturn(Mockito.mock(NewMediaItemResult.class));
    JobStore jobStore = new LocalJobStore();
    InputStream inputStream = Mockito.mock(InputStream.class);
    imageStreamProvider = Mockito.mock(ImageStreamProvider.class);
    HttpURLConnection conn = Mockito.mock(HttpURLConnection.class);
    Mockito.when(imageStreamProvider.getConnection(anyString())).thenReturn(conn);
    Mockito.when(conn.getInputStream()).thenReturn(inputStream);
    Mockito.when(conn.getContentLengthLong()).thenReturn(32L);
    googlePhotosImporter = new GooglePhotosImporter(null, jobStore, null, null, googlePhotosInterface, imageStreamProvider, monitor, 1.0);
}
Also used : LocalJobStore(org.datatransferproject.cloud.local.LocalJobStore) Monitor(org.datatransferproject.api.launcher.Monitor) HttpURLConnection(java.net.HttpURLConnection) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) NewMediaItemResult(org.datatransferproject.datatransfer.google.mediaModels.NewMediaItemResult) ImageStreamProvider(org.datatransferproject.transfer.ImageStreamProvider) LocalJobStore(org.datatransferproject.cloud.local.LocalJobStore) JobStore(org.datatransferproject.spi.cloud.storage.JobStore) InMemoryIdempotentImportExecutor(org.datatransferproject.spi.transfer.idempotentexecutor.InMemoryIdempotentImportExecutor) Before(org.junit.Before)

Aggregations

Monitor (org.datatransferproject.api.launcher.Monitor)2 LocalJobStore (org.datatransferproject.cloud.local.LocalJobStore)2 Before (org.junit.Before)2 Scheduler (com.google.common.util.concurrent.AbstractScheduledService.Scheduler)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 ExtensionContext (org.datatransferproject.api.launcher.ExtensionContext)1 NewMediaItemResult (org.datatransferproject.datatransfer.google.mediaModels.NewMediaItemResult)1 JobStore (org.datatransferproject.spi.cloud.storage.JobStore)1 InMemoryIdempotentImportExecutor (org.datatransferproject.spi.transfer.idempotentexecutor.InMemoryIdempotentImportExecutor)1 PublicKeySerializer (org.datatransferproject.spi.transfer.security.PublicKeySerializer)1 ImageStreamProvider (org.datatransferproject.transfer.ImageStreamProvider)1