Search in sources :

Example 16 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class GoogleDriveDeleteReaderTest method delete.

private void delete() throws java.io.IOException {
    source.initialize(container, properties);
    BoundedReader reader = source.createReader(container);
    assertTrue(reader.start());
    IndexedRecord record = (IndexedRecord) reader.getCurrent();
    assertNotNull(record);
    assertEquals(1, record.getSchema().getFields().size());
    assertEquals(FOLDER_DELETE_ID, record.get(0));
    reader.close();
    Map<String, Object> returnValues = reader.getReturnValues();
    assertNotNull(returnValues);
    assertEquals(FOLDER_DELETE_ID, returnValues.get(GoogleDriveDeleteDefinition.RETURN_FILE_ID));
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Matchers.anyString(org.mockito.Matchers.anyString) BoundedReader(org.talend.components.api.component.runtime.BoundedReader)

Example 17 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class GoogleDriveGetReaderTest method testStart.

@Test
public void testStart() throws Exception {
    ValidationResult vr = source.initialize(container, properties);
    assertNotNull(vr);
    assertEquals(Result.OK, vr.getStatus());
    BoundedReader reader = source.createReader(container);
    assertTrue(reader.start());
    IndexedRecord record = (IndexedRecord) reader.getCurrent();
    assertNotNull(record);
    assertEquals(1, record.getSchema().getFields().size());
    assertFalse(reader.advance());
    reader.close();
    Map<String, Object> returnValues = reader.getReturnValues();
    assertEquals(FILE_GET_ID, returnValues.get(GoogleDriveGetDefinition.RETURN_FILE_ID));
    assertNull(returnValues.get(GoogleDriveGetDefinition.RETURN_CONTENT));
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Matchers.anyString(org.mockito.Matchers.anyString) ValidationResult(org.talend.daikon.properties.ValidationResult) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 18 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class TAzureStorageInputTableTestIT method testFilterReader.

@SuppressWarnings({ "rawtypes" })
@Test
public void testFilterReader() throws Throwable {
    Date startTest = new Date();
    String sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm").format(startTest);
    Thread.sleep(2000);
    String ctable = tbl_test + "InputFilter";
    createSampleDataset(ctable);
    properties.tableName.setValue(ctable);
    properties.useFilterExpression.setValue(true);
    List<String> cols = Arrays.asList("PartitionKey", "Timestamp");
    List<String> ops = Arrays.asList(pk_test1, sdf);
    List<String> funs = Arrays.asList(Comparison.EQUAL.toString(), Comparison.GREATER_THAN.toString());
    List<String> preds = Arrays.asList(Predicate.AND.toString(), Predicate.AND.toString());
    List<String> types = Arrays.asList(SupportedFieldType.STRING.toString(), SupportedFieldType.DATE.toString());
    properties.filterExpression.column.setValue(cols);
    properties.filterExpression.function.setValue(funs);
    properties.filterExpression.operand.setValue(ops);
    properties.filterExpression.predicate.setValue(preds);
    properties.filterExpression.fieldType.setValue(types);
    properties.schema.schema.setValue(getDynamicSchema());
    BoundedReader reader = createBoundedReader(properties);
    assertTrue(reader.start());
    while (reader.advance()) {
        IndexedRecord current = (IndexedRecord) reader.getCurrent();
        assertNotNull(current);
        assertEquals(5, current.getSchema().getFields().size());
        assertEquals(pk_test1, current.get(0));
        assertTrue(((Date) current.get(2)).after(startTest));
    }
    reader.close();
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 19 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class TAzureStorageInputTableTestIT method testSystemReader.

@SuppressWarnings("rawtypes")
@Test
public void testSystemReader() throws Throwable {
    String ctable = tbl_test + "InputSys";
    createSampleDataset(ctable);
    properties.tableName.setValue(ctable);
    properties.schema.schema.setValue(getSystemSchema());
    properties.useFilterExpression.setValue(false);
    BoundedReader reader = createBoundedReader(properties);
    assertTrue(reader.start());
    while (reader.advance()) {
        IndexedRecord current = (IndexedRecord) reader.getCurrent();
        assertNotNull(current);
        assertEquals(getSystemSchema(), current.getSchema());
        assertEquals(3, current.getSchema().getFields().size());
    }
    reader.close();
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 20 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class AzureStorageGetReaderTestIT method testBlobGetAll.

@SuppressWarnings("rawtypes")
@Test
public void testBlobGetAll() throws Exception {
    cleanupLists();
    prefixes.add("");
    includes.add(true);
    creates.add(true);
    BoundedReader reader = createGetReader(false);
    assertTrue(reader.start());
    reader.close();
    for (String file : TEST_ALL_BLOBS) assertTrue(fileExistsAndHasTheGoodSize(file));
}
Also used : BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Aggregations

BoundedReader (org.talend.components.api.component.runtime.BoundedReader)45 Test (org.junit.Test)37 IndexedRecord (org.apache.avro.generic.IndexedRecord)24 Matchers.anyString (org.mockito.Matchers.anyString)6 ArrayList (java.util.ArrayList)5 TAzureStorageQueueCreateProperties (org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties)4 GenericData (org.apache.avro.generic.GenericData)3 RemoteBlobsTable (org.talend.components.azurestorage.blob.helpers.RemoteBlobsTable)2 TAzureStorageQueueDeleteProperties (org.talend.components.azurestorage.queue.tazurestoragequeuedelete.TAzureStorageQueueDeleteProperties)2 Drive (com.google.api.services.drive.Drive)1 File (com.google.api.services.drive.model.File)1 FileList (com.google.api.services.drive.model.FileList)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Map (java.util.Map)1 Before (org.junit.Before)1 TAzureStorageContainerCreateProperties (org.talend.components.azurestorage.blob.tazurestoragecontainercreate.TAzureStorageContainerCreateProperties)1 TAzureStorageContainerDeleteProperties (org.talend.components.azurestorage.blob.tazurestoragecontainerdelete.TAzureStorageContainerDeleteProperties)1 TAzureStorageContainerExistProperties (org.talend.components.azurestorage.blob.tazurestoragecontainerexist.TAzureStorageContainerExistProperties)1 TAzureStorageContainerListProperties (org.talend.components.azurestorage.blob.tazurestoragecontainerlist.TAzureStorageContainerListProperties)1