use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceDataprepSource method initialize.
@Override
public ValidationResult initialize(RuntimeContainer container, ComponentProperties properties) {
this.properties = (SalesforceInputProperties) properties;
dataset = this.properties.getDatasetProperties();
datastore = dataset.getDatastoreProperties();
String config_file = System.getProperty(CONFIG_FILE_lOCATION_KEY);
try (InputStream is = config_file != null ? (new FileInputStream(config_file)) : null) {
if (is == null) {
LOG.warn("not found the property file, will use the default value for endpoint and timeout");
return ValidationResult.OK;
}
Properties props = new Properties();
props.load(is);
String endpoint = props.getProperty("endpoint");
if (endpoint != null && !endpoint.isEmpty()) {
this.endpoint = endpoint;
}
String timeout = props.getProperty("timeout");
if (timeout != null && !timeout.isEmpty()) {
this.timeout = Integer.parseInt(timeout);
}
} catch (IOException e) {
LOG.warn("not found the property file, will use the default value for endpoint and timeout", e);
}
return ValidationResult.OK;
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method testTypeForModule.
@Test
public void testTypeForModule() throws Exception {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("IsDeleted", "Id"));
try (Reader reader = source.createReader(null)) {
int count = 3;
for (boolean available = reader.start(); available; available = reader.advance()) {
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertEquals(String.class, record.get(0).getClass());
assertEquals(String.class, record.get(1).getClass());
if ((count--) < 1) {
break;
}
}
}
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method testTypeForModuleWithBadQuery.
@Test(expected = RuntimeException.class)
public void testTypeForModuleWithBadQuery() throws Exception {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("Toto"));
try (Reader reader = source.createReader(null)) {
reader.start();
}
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method testTypeForModuleWithoutSpecifiedFields.
@Test
public void testTypeForModuleWithoutSpecifiedFields() throws Exception {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("IsDeleted", "Id", "Name"));
try (Reader reader = source.createReader(null)) {
int count = 3;
for (boolean available = reader.start(); available; available = reader.advance()) {
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertEquals(3, record.getSchema().getFields().size());
if ((count--) < 1) {
break;
}
}
}
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method testTypeForModuleWithCompoundType.
@Test(expected = ComponentException.class)
public void testTypeForModuleWithCompoundType() throws Exception {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("IsDeleted", "Id", "Name", "BillingAddress", "ShippingAddress"));
try (Reader reader = source.createReader(null)) {
reader.start();
}
}
Aggregations