use of org.datatransferproject.api.launcher.Monitor in project data-transfer-project by google.
the class KoofrClientTest method setUp.
@Before
public void setUp() throws IOException {
server = new MockWebServer();
server.start();
httpClient = new OkHttpClient.Builder().build();
mapper = new ObjectMapper();
monitor = mock(Monitor.class);
credentialFactory = mock(KoofrCredentialFactory.class);
credential = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod()).build();
credential.setAccessToken("acc");
credential.setExpirationTimeMilliseconds(null);
when(credentialFactory.createCredential(any())).thenReturn(credential);
client = new KoofrClient(server.url("").toString(), httpClient, httpClient, mapper, monitor, credentialFactory);
authData = new TokensAndUrlAuthData("acc", "refresh", "");
client.getOrCreateCredential(authData);
}
use of org.datatransferproject.api.launcher.Monitor in project data-transfer-project by google.
the class KoofrPhotosExporterTest method setUp.
@Before
public void setUp() throws Exception {
client = mock(KoofrClient.class);
clientFactory = mock(KoofrClientFactory.class);
when(clientFactory.create(any())).thenReturn(client);
monitor = mock(Monitor.class);
exporter = new KoofrPhotosExporter(clientFactory, monitor);
authData = new TokensAndUrlAuthData("acc", "refresh", "");
}
use of org.datatransferproject.api.launcher.Monitor in project data-transfer-project by google.
the class SpotifyTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
if (initialized) {
Monitor monitor = context.getMonitor();
monitor.severe(() -> "SpotifyTransferExtension already initialized");
return;
}
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("SPOTIFY_KEY", "SPOTIFY_SECRET");
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> "Unable to retrieve Spotify AppCredentials. " + "Did you set SPOTIFY_KEY and SPOTIFY_SECRET?");
return;
}
Monitor monitor = context.getMonitor();
SpotifyApi spotifyApi = new SpotifyApi.Builder().setClientId(appCredentials.getKey()).setClientSecret(appCredentials.getSecret()).build();
exporter = new SpotifyPlaylistExporter(monitor, spotifyApi);
importer = new SpotifyPlaylistImporter(monitor, spotifyApi);
initialized = true;
}
use of org.datatransferproject.api.launcher.Monitor in project data-transfer-project by google.
the class DataTypesActionTest method testGetRequestType.
@Test
public void testGetRequestType() {
AuthServiceProviderRegistry registry = mock(AuthServiceProviderRegistry.class);
DataTypesAction dataTypesAction = new DataTypesAction(registry, new Monitor() {
});
Class<GetDataTypes> actual = dataTypesAction.getRequestType();
Assert.assertNotEquals(actual, null);
Assert.assertEquals(actual, GetDataTypes.class);
}
use of org.datatransferproject.api.launcher.Monitor in project data-transfer-project by google.
the class GoogleTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
// times.
if (initialized)
return;
JobStore jobStore = context.getService(JobStore.class);
HttpTransport httpTransport = context.getService(HttpTransport.class);
JsonFactory jsonFactory = context.getService(JsonFactory.class);
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("GOOGLE_KEY", "GOOGLE_SECRET");
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> "Unable to retrieve Google AppCredentials. Did you set GOOGLE_KEY and GOOGLE_SECRET?");
return;
}
Monitor monitor = context.getMonitor();
// Create the GoogleCredentialFactory with the given {@link AppCredentials}.
GoogleCredentialFactory credentialFactory = new GoogleCredentialFactory(httpTransport, jsonFactory, appCredentials, monitor);
ImmutableMap.Builder<String, Importer> importerBuilder = ImmutableMap.builder();
importerBuilder.put("BLOBS", new DriveImporter(credentialFactory, jobStore, monitor));
importerBuilder.put("CONTACTS", new GoogleContactsImporter(credentialFactory));
importerBuilder.put("CALENDAR", new GoogleCalendarImporter(credentialFactory));
importerBuilder.put("MAIL", new GoogleMailImporter(credentialFactory, monitor));
importerBuilder.put("TASKS", new GoogleTasksImporter(credentialFactory));
importerBuilder.put("PHOTOS", new GooglePhotosImporter(credentialFactory, jobStore, jsonFactory, monitor, context.getSetting("googleWritesPerSecond", 1.0)));
importerBuilder.put("VIDEOS", new GoogleVideosImporter(appCredentials, jobStore, monitor));
importerMap = importerBuilder.build();
ImmutableMap.Builder<String, Exporter> exporterBuilder = ImmutableMap.builder();
exporterBuilder.put("BLOBS", new DriveExporter(credentialFactory, jobStore, monitor));
exporterBuilder.put("CONTACTS", new GoogleContactsExporter(credentialFactory));
exporterBuilder.put("CALENDAR", new GoogleCalendarExporter(credentialFactory));
exporterBuilder.put("MAIL", new GoogleMailExporter(credentialFactory));
exporterBuilder.put("SOCIAL-POSTS", new GooglePlusExporter(credentialFactory));
exporterBuilder.put("TASKS", new GoogleTasksExporter(credentialFactory, monitor));
exporterBuilder.put("PHOTOS", new GooglePhotosExporter(credentialFactory, jobStore, jsonFactory, monitor));
exporterBuilder.put("VIDEOS", new GoogleVideosExporter(credentialFactory, jsonFactory));
exporterMap = exporterBuilder.build();
initialized = true;
}
Aggregations