Search in sources :

Example 16 with SalesforceInputProperties

use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.

the class SalesforceInputTestIT method testReaderForModule.

@Test
public void testReaderForModule() {
    Reader reader = null;
    try {
        SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
        properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("IsDeleted", "Id"));
        SalesforceDataprepSource source = new SalesforceDataprepSource();
        source.initialize(null, properties);
        source.validate(null);
        reader = source.createReader(null);
        reader.start();
        IndexedRecord row = (IndexedRecord) reader.getCurrent();
        String id = (String) row.get(0);
        Assert.assertNotNull("id is null", id);
        reader.advance();
        row = (IndexedRecord) reader.getCurrent();
        Assert.assertNotNull("id is null", id);
        reader.close();
    // Map<String, Object> returnMap = reader.getReturnValues();
    // Assert.assertEquals(3, returnMap.get(ComponentDefinition.RETURN_TOTAL_RECORD_COUNT));
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e) {
                Assert.fail(e.getMessage());
            }
        }
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Reader(org.talend.components.api.component.runtime.Reader) SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties) IOException(java.io.IOException) ComponentException(org.talend.components.api.exception.ComponentException) IOException(java.io.IOException) Test(org.junit.Test)

Example 17 with SalesforceInputProperties

use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.

the class SalesforceDatasetRuntime method getSchema.

@Override
public Schema getSchema() {
    SalesforceDataprepSource sds = new SalesforceDataprepSource();
    SalesforceInputProperties properties = new SalesforceInputProperties("model");
    properties.setDatasetProperties(dataset);
    sds.initialize(container, properties);
    sds.validate(container);
    try {
        // TODO the UI will be a radio, need to adjust here
        return SalesforceSchemaUtils.getSchema(dataset, sds, container);
    } catch (IOException e) {
        throw new ComponentException(e);
    }
}
Also used : ComponentException(org.talend.components.api.exception.ComponentException) SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties) IOException(java.io.IOException)

Aggregations

SalesforceInputProperties (org.talend.components.salesforce.dataprep.SalesforceInputProperties)17 Reader (org.talend.components.api.component.runtime.Reader)9 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 Test (org.junit.Test)8 IOException (java.io.IOException)5 SalesforceDatasetProperties (org.talend.components.salesforce.dataset.SalesforceDatasetProperties)4 ComponentException (org.talend.components.api.exception.ComponentException)3 SalesforceDatastoreProperties (org.talend.components.salesforce.datastore.SalesforceDatastoreProperties)3 SalesforceInputDefinition (org.talend.components.salesforce.dataprep.SalesforceInputDefinition)2 SalesforceDatastoreDefinition (org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 ReaderDataProvider (org.talend.components.api.component.runtime.ReaderDataProvider)1 ComponentProperties (org.talend.components.api.properties.ComponentProperties)1 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)1 SalesforceDefinition.getSandboxedInstance (org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance)1 SalesforceRuntimeSourceOrSink (org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1