Search in sources :

Example 11 with BoundedReader

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

the class AzureStorageContainerListReaderTestIT method testContainerList.

@SuppressWarnings("rawtypes")
@Test
public void testContainerList() throws Exception {
    BoundedReader reader = createContainerListReader();
    List<String> containers = new ArrayList<>();
    Boolean rows = reader.start();
    Object row;
    assertTrue(rows);
    // 
    while (rows) {
        row = ((IndexedRecord) reader.getCurrent()).get(0);
        assertNotNull(row);
        assertTrue(row instanceof String);
        containers.add(row.toString());
        rows = reader.advance();
    }
    reader.close();
    assertTrue(isTestContainerInContainerList(containers));
}
Also used : ArrayList(java.util.ArrayList) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 12 with BoundedReader

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

the class TAzureStorageConnectionTestIT method testInvalidConnection.

@SuppressWarnings("rawtypes")
@Test(expected = Exception.class)
public void testInvalidConnection() throws Throwable {
    TAzureStorageContainerListProperties properties = new TAzureStorageContainerListProperties("test");
    properties.dieOnError.setValue(true);
    BoundedReader reader = createBoundedReader(properties);
    reader.start();
}
Also used : TAzureStorageContainerListProperties(org.talend.components.azurestorage.blob.tazurestoragecontainerlist.TAzureStorageContainerListProperties) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 13 with BoundedReader

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

the class SalesforceBulkExecReaderTestIT method executeBulkInsert.

/**
 * Test runtime of tSalesforceOutputBulk
 */
private void executeBulkInsert(TSalesforceBulkExecProperties bulkExecProperties, String random, int count) throws Throwable {
    TSalesforceBulkExecDefinition definition = (TSalesforceBulkExecDefinition) getComponentService().getComponentDefinition(TSalesforceBulkExecDefinition.COMPONENT_NAME);
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(ExecutionEngine.DI, bulkExecProperties, ConnectorTopology.OUTGOING);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, definition.getClass().getClassLoader())) {
        SalesforceSource boundedSource = (SalesforceSource) sandboxedInstance.getInstance();
        boundedSource.initialize(null, bulkExecProperties);
        BoundedReader boundedReader = boundedSource.createReader(null);
        try {
            boolean hasRecord = boundedReader.start();
            List<IndexedRecord> rows = new ArrayList<>();
            while (hasRecord) {
                rows.add((IndexedRecord) boundedReader.getCurrent());
                hasRecord = boundedReader.advance();
            }
            checkRows(random, rows, count);
        } finally {
            boundedReader.close();
        }
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) IndexedRecord(org.apache.avro.generic.IndexedRecord) TSalesforceBulkExecDefinition(org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecDefinition) ArrayList(java.util.ArrayList) BoundedReader(org.talend.components.api.component.runtime.BoundedReader)

Example 14 with BoundedReader

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

the class TAzureStorageInputTableTestIT method testNameMappings.

@SuppressWarnings("rawtypes")
@Test
public void testNameMappings() throws Throwable {
    String ctable = tbl_test + "InputNameMappings";
    createSampleDataset(ctable);
    properties.tableName.setValue(ctable);
    properties.useFilterExpression.setValue(false);
    properties.schema.schema.setValue(getMappingSchema());
    properties.nameMapping.schemaColumnName.setValue(schemaMappings);
    properties.nameMapping.entityPropertyName.setValue(propertyMappings);
    BoundedReader reader = createBoundedReader(properties);
    IndexedRecord current = null;
    assertTrue(reader.start());
    while (reader.advance()) {
        current = (IndexedRecord) reader.getCurrent();
        assertNotNull(current);
        assertEquals(getMappingSchema(), current.getSchema());
        assertNotNull(current.getSchema().getField("pk"));
        assertNotNull(current.getSchema().getField("rk"));
        assertNotNull(current.getSchema().getField("ts"));
        assertNotNull(current.getSchema().getField("electronicMail"));
        assertNotNull(current.getSchema().getField("telephoneNumber"));
    }
    reader.close();
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 15 with BoundedReader

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

the class TAzureStorageInputTableTestIT method testFirstReader.

@SuppressWarnings("rawtypes")
@Test
public void testFirstReader() throws Throwable {
    String ctable = tbl_test + "InputSimple";
    createSampleDataset(ctable);
    properties.tableName.setValue(ctable);
    properties.useFilterExpression.setValue(false);
    properties.schema.schema.setValue(null);
    BoundedReader reader = createBoundedReader(properties);
    assertTrue(reader.start());
    while (reader.advance()) {
        IndexedRecord current = (IndexedRecord) reader.getCurrent();
        assertNotNull(current);
    }
    reader.close();
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) 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