Search in sources :

Example 1 with About

use of com.google.api.services.drive.model.About in project components by Talend.

the class GoogleDriveRuntimeTest method testValidateConnection.

@Test
public void testValidateConnection() throws Exception {
    About about = new About();
    User user = new User();
    user.setEmailAddress("test@example.org");
    about.setUser(user);
    when(drive.about().get().setFields(anyString()).execute()).thenReturn(about);
    assertEquals(Result.OK, testRuntime.validateConnection(testRuntime.getConnectionProperties()).getStatus());
}
Also used : User(com.google.api.services.drive.model.User) About(com.google.api.services.drive.model.About) Test(org.junit.Test)

Example 2 with About

use of com.google.api.services.drive.model.About in project components by Talend.

the class GoogleDriveDataSourceTest method testValidate.

@Test
public void testValidate() throws Exception {
    dataSource.initialize(container, inputProperties);
    assertEquals(Result.ERROR, dataSource.validate(container).getStatus());
    dataSource = spy(dataSource);
    Drive drive = mock(Drive.class, RETURNS_DEEP_STUBS);
    GoogleDriveUtils utils = mock(GoogleDriveUtils.class, RETURNS_DEEP_STUBS);
    doReturn(drive).when(dataSource).getDriveService();
    doReturn(utils).when(dataSource).getDriveUtils();
    inputProperties.getDatasetProperties().getDatastoreProperties().serviceAccountJSONFile.setValue("service.json");
    dataSource.initialize(container, inputProperties);
    About about = new About();
    User user = new User();
    user.setEmailAddress("test@example.org");
    about.setUser(user);
    when(drive.about().get().setFields(anyString()).execute()).thenReturn(about);
    assertEquals(Result.OK, dataSource.validate(container).getStatus());
}
Also used : User(com.google.api.services.drive.model.User) Drive(com.google.api.services.drive.Drive) GoogleDriveUtils(org.talend.components.google.drive.runtime.GoogleDriveUtils) About(com.google.api.services.drive.model.About) Test(org.junit.Test)

Example 3 with About

use of com.google.api.services.drive.model.About in project keepass2android by PhilippC.

the class GoogleDriveFileStorage method finishInitialization.

private void finishInitialization(AccountData newAccountData, String accountName) throws IOException {
    if (TextUtils.isEmpty(newAccountData.mRootFolderId)) {
        logDebug("Finish init account for " + accountName);
        About about = newAccountData.drive.about().get().execute();
        newAccountData.mRootFolderId = about.getRootFolderId();
    } else {
        logDebug("Account for " + accountName + " already fully initialized.");
    }
}
Also used : About(com.google.api.services.drive.model.About)

Aggregations

About (com.google.api.services.drive.model.About)3 User (com.google.api.services.drive.model.User)2 Test (org.junit.Test)2 Drive (com.google.api.services.drive.Drive)1 GoogleDriveUtils (org.talend.components.google.drive.runtime.GoogleDriveUtils)1