Search in sources :

Example 1 with GoogleDrivePutProperties

use of org.talend.components.google.drive.put.GoogleDrivePutProperties in project components by Talend.

the class GoogleDrivePutRuntimeTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    properties = new GoogleDrivePutProperties("test");
    properties.connection.setupProperties();
    properties.connection.setupLayout();
    properties.schemaMain.setupProperties();
    properties.schemaMain.setupLayout();
    properties.setupProperties();
    properties.setupLayout();
    properties = (GoogleDrivePutProperties) setupConnectionWithAccessToken(properties);
    properties.uploadMode.setValue(UploadMode.UPLOAD_LOCAL_FILE);
    properties.fileName.setValue(FILE_PUT_NAME);
    properties.localFilePath.setValue("c:/Users/undx/brasil.jpg");
    properties.overwrite.setValue(true);
    properties.destinationFolder.setValue("root");
    testRuntime = spy(GoogleDrivePutRuntime.class);
    doReturn(drive).when(testRuntime).getDriveService();
    when(drive.files().list().setQ(anyString()).execute()).thenReturn(emptyFileList);
    // 
    File putFile = new File();
    putFile.setId(PUT_FILE_ID);
    putFile.setParents(Collections.singletonList(PUT_FILE_PARENT_ID));
    when(drive.files().create(any(File.class), any(AbstractInputStreamContent.class)).setFields(anyString()).execute()).thenReturn(putFile);
}
Also used : GoogleDrivePutProperties(org.talend.components.google.drive.put.GoogleDrivePutProperties) File(com.google.api.services.drive.model.File) AbstractInputStreamContent(com.google.api.client.http.AbstractInputStreamContent) Before(org.junit.Before)

Example 2 with GoogleDrivePutProperties

use of org.talend.components.google.drive.put.GoogleDrivePutProperties in project components by Talend.

the class GoogleDriveWriteOperationTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    properties = new GoogleDrivePutProperties("test");
    properties.connection.setupProperties();
    properties.connection.setupLayout();
    properties.schemaMain.setupProperties();
    properties.schemaMain.setupLayout();
    properties = (GoogleDrivePutProperties) setupConnectionWithInstalledApplicationWithIdAndSecret(properties);
    properties.setupLayout();
    sink = new GoogleDriveSink();
    sink.initialize(container, properties);
    wop = new GoogleDriveWriteOperation(sink);
}
Also used : GoogleDrivePutProperties(org.talend.components.google.drive.put.GoogleDrivePutProperties) Before(org.junit.Before)

Example 3 with GoogleDrivePutProperties

use of org.talend.components.google.drive.put.GoogleDrivePutProperties in project components by Talend.

the class GoogleDrivePutWriterTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    properties = new GoogleDrivePutProperties("test");
    properties.connection.setupProperties();
    properties.connection.setupLayout();
    properties.schemaMain.setupProperties();
    properties.schemaMain.setupLayout();
    properties.setupProperties();
    properties.setupLayout();
    properties = (GoogleDrivePutProperties) setupConnectionWithAccessToken(properties);
    properties.uploadMode.setValue(UploadMode.UPLOAD_LOCAL_FILE);
    properties.fileName.setValue("GoogleDrive Put test BR");
    properties.localFilePath.setValue("c:/Users/undx/brasil.jpg");
    properties.overwrite.setValue(true);
    properties.destinationFolder.setValue("root");
    sink.initialize(container, properties);
    wop = (GoogleDriveWriteOperation) sink.createWriteOperation();
    writer = new GoogleDrivePutWriter(wop, properties, container);
    when(drive.files().list().setQ(anyString()).execute()).thenReturn(emptyFileList);
    // 
    File putFile = new File();
    putFile.setId(PUT_FILE_ID);
    putFile.setParents(Collections.singletonList(PUT_FILE_PARENT_ID));
    when(drive.files().create(any(File.class), any(AbstractInputStreamContent.class)).setFields(anyString()).execute()).thenReturn(putFile);
}
Also used : GoogleDrivePutProperties(org.talend.components.google.drive.put.GoogleDrivePutProperties) File(com.google.api.services.drive.model.File) AbstractInputStreamContent(com.google.api.client.http.AbstractInputStreamContent) Before(org.junit.Before)

Example 4 with GoogleDrivePutProperties

use of org.talend.components.google.drive.put.GoogleDrivePutProperties in project components by Talend.

the class GoogleDrivePutReaderTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    properties = new GoogleDrivePutProperties("test");
    properties.connection.setupProperties();
    properties.connection.setupLayout();
    properties.schemaMain.setupProperties();
    properties.schemaMain.setupLayout();
    properties.setupProperties();
    properties.setupLayout();
    properties = (GoogleDrivePutProperties) setupConnectionWithAccessToken(properties);
    properties.uploadMode.setValue(UploadMode.UPLOAD_LOCAL_FILE);
    properties.fileName.setValue(FILE_PUT_NAME);
    properties.localFilePath.setValue(Paths.get(getClass().getClassLoader().getResource("service_account.json").toURI()).toString());
    properties.overwrite.setValue(true);
    properties.destinationFolder.setValue("root");
    when(drive.files().list().setQ(anyString()).execute()).thenReturn(emptyFileList);
    // 
    File putFile = new File();
    putFile.setId(PUT_FILE_ID);
    putFile.setParents(Collections.singletonList(PUT_FILE_PARENT_ID));
    when(drive.files().create(any(File.class), any(AbstractInputStreamContent.class)).setFields(anyString()).execute()).thenReturn(putFile);
}
Also used : GoogleDrivePutProperties(org.talend.components.google.drive.put.GoogleDrivePutProperties) File(com.google.api.services.drive.model.File) AbstractInputStreamContent(com.google.api.client.http.AbstractInputStreamContent) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)4 GoogleDrivePutProperties (org.talend.components.google.drive.put.GoogleDrivePutProperties)4 AbstractInputStreamContent (com.google.api.client.http.AbstractInputStreamContent)3 File (com.google.api.services.drive.model.File)3