Search in sources :

Example 6 with SalesforceDatasetProperties

use of org.talend.components.salesforce.dataset.SalesforceDatasetProperties in project components by Talend.

the class SalesforceDatastoreDefinition method createDatasetProperties.

@SuppressWarnings("rawtypes")
@Override
public DatasetProperties createDatasetProperties(SalesforceDatastoreProperties storeProp) {
    SalesforceDatasetProperties datasetProperties = new SalesforceDatasetProperties("dataset");
    datasetProperties.init();
    datasetProperties.setDatastoreProperties(storeProp);
    return datasetProperties;
}
Also used : SalesforceDatasetProperties(org.talend.components.salesforce.dataset.SalesforceDatasetProperties)

Example 7 with SalesforceDatasetProperties

use of org.talend.components.salesforce.dataset.SalesforceDatasetProperties in project components by Talend.

the class SalesforceDatastoreRuntime method doHealthChecks.

@Override
public Iterable<ValidationResult> doHealthChecks(RuntimeContainer container) {
    SalesforceDataprepSource sds = new SalesforceDataprepSource();
    SalesforceInputProperties properties = new SalesforceInputProperties("model");
    SalesforceDatasetProperties dataset = new SalesforceDatasetProperties("dataset");
    // set the sourcetype to soql to prevent loading of all modules during health check
    dataset.sourceType.setValue(SalesforceDatasetProperties.SourceType.SOQL_QUERY);
    properties.setDatasetProperties(dataset);
    dataset.setDatastoreProperties(datastore);
    sds.initialize(container, properties);
    ValidationResult result = sds.validate(container);
    return Arrays.asList(result);
}
Also used : SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) SalesforceDatasetProperties(org.talend.components.salesforce.dataset.SalesforceDatasetProperties)

Example 8 with SalesforceDatasetProperties

use of org.talend.components.salesforce.dataset.SalesforceDatasetProperties in project components by Talend.

the class SalesforceDatasetRuntimeTestIT method testGetSampleForQuery.

@Test
public void testGetSampleForQuery() {
    SalesforceDatasetProperties dataset = createDatasetPropertiesForQuery();
    getSampleAction(dataset);
}
Also used : SalesforceDatasetProperties(org.talend.components.salesforce.dataset.SalesforceDatasetProperties) Test(org.junit.Test)

Example 9 with SalesforceDatasetProperties

use of org.talend.components.salesforce.dataset.SalesforceDatasetProperties in project components by Talend.

the class SalesforceDatasetRuntimeTestIT method createDatasetPropertiesForQuery.

private SalesforceDatasetProperties createDatasetPropertiesForQuery() {
    SalesforceDatastoreDefinition def = new SalesforceDatastoreDefinition();
    SalesforceDatastoreProperties datastore = new SalesforceDatastoreProperties("datastore");
    CommonTestUtils.setValueForDatastoreProperties(datastore);
    SalesforceDatasetProperties dataset = (SalesforceDatasetProperties) def.createDatasetProperties(datastore);
    dataset.sourceType.setValue(SalesforceDatasetProperties.SourceType.SOQL_QUERY);
    dataset.query.setValue("SELECT Id, Name FROM Account");
    return dataset;
}
Also used : SalesforceDatastoreProperties(org.talend.components.salesforce.datastore.SalesforceDatastoreProperties) SalesforceDatastoreDefinition(org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition) SalesforceDatasetProperties(org.talend.components.salesforce.dataset.SalesforceDatasetProperties)

Example 10 with SalesforceDatasetProperties

use of org.talend.components.salesforce.dataset.SalesforceDatasetProperties in project components by Talend.

the class SalesforceDatasetRuntimeTestIT method testGetSampleWithRelationshipQuery.

@Test
public void testGetSampleWithRelationshipQuery() {
    SalesforceDatastoreDefinition def = new SalesforceDatastoreDefinition();
    SalesforceDatastoreProperties datastore = new SalesforceDatastoreProperties("datastore");
    CommonTestUtils.setValueForDatastoreProperties(datastore);
    SalesforceDatasetProperties dataset = (SalesforceDatasetProperties) def.createDatasetProperties(datastore);
    dataset.sourceType.setValue(SalesforceDatasetProperties.SourceType.SOQL_QUERY);
    dataset.query.setValue("SELECT Account.Name from Contact");
    SalesforceDatasetRuntime runtime = new SalesforceDatasetRuntime();
    runtime.initialize(null, dataset);
    final IndexedRecord[] record = new IndexedRecord[1];
    Consumer<IndexedRecord> storeTheRecords = new Consumer<IndexedRecord>() {

        @Override
        public void accept(IndexedRecord data) {
            record[0] = data;
        }
    };
    runtime.getSample(1, storeTheRecords);
    Assert.assertTrue("empty result", record.length > 0);
    Assert.assertNotNull(record[0].getSchema().getField("Account_Name"));
}
Also used : SalesforceDatastoreProperties(org.talend.components.salesforce.datastore.SalesforceDatastoreProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) Consumer(org.talend.daikon.java8.Consumer) SalesforceDatastoreDefinition(org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition) SalesforceDatasetProperties(org.talend.components.salesforce.dataset.SalesforceDatasetProperties) Test(org.junit.Test)

Aggregations

SalesforceDatasetProperties (org.talend.components.salesforce.dataset.SalesforceDatasetProperties)13 Test (org.junit.Test)5 SalesforceDatastoreDefinition (org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition)5 SalesforceDatastoreProperties (org.talend.components.salesforce.datastore.SalesforceDatastoreProperties)5 SalesforceInputProperties (org.talend.components.salesforce.dataprep.SalesforceInputProperties)3 Schema (org.apache.avro.Schema)2 Before (org.junit.Before)2 SalesforceInputDefinition (org.talend.components.salesforce.dataprep.SalesforceInputDefinition)2 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 Consumer (org.talend.daikon.java8.Consumer)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1