use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method testLimitOfSalesforceBulQueryReader.
public void testLimitOfSalesforceBulQueryReader() 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)) {
((SalesforceBulkQueryReader) reader).setLimit(1);
reader.start();
reader.advance();
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertEquals(3, record.getSchema().getFields().size());
try {
reader.advance();
fail();
} catch (IOException e) {
// Excepted to happen
}
}
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method createCommonSalesforceInputPropertiesForModule.
private SalesforceInputProperties createCommonSalesforceInputPropertiesForModule() {
SalesforceDatastoreDefinition datastore_def = new SalesforceDatastoreDefinition();
SalesforceDatastoreProperties datastore_props = new SalesforceDatastoreProperties("datastore");
CommonTestUtils.setValueForDatastoreProperties(datastore_props);
SalesforceDatasetProperties dataset = (SalesforceDatasetProperties) datastore_def.createDatasetProperties(datastore_props);
dataset.moduleName.setValue("Account");
SalesforceInputDefinition input_def = new SalesforceInputDefinition();
SalesforceInputProperties input_props = (SalesforceInputProperties) input_def.createRuntimeProperties();
input_props.setDatasetProperties(dataset);
List<String> products = input_def.getSupportedProducts();
assertNotNull(products);
assertEquals(1, products.size());
assertEquals(SupportedProduct.DATAPREP, products.get(0));
return input_props;
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method testReaderForQuery.
@Test
public void testReaderForQuery() {
Reader reader = null;
try {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForQuery();
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);
String name = (String) row.get(1);
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());
}
}
}
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method createCommonSalesforceInputPropertiesForQuery.
private SalesforceInputProperties createCommonSalesforceInputPropertiesForQuery() {
SalesforceDatastoreDefinition datastore_def = new SalesforceDatastoreDefinition();
SalesforceDatastoreProperties datastore_props = new SalesforceDatastoreProperties("datastore");
CommonTestUtils.setValueForDatastoreProperties(datastore_props);
SalesforceDatasetProperties dataset = (SalesforceDatasetProperties) datastore_def.createDatasetProperties(datastore_props);
dataset.sourceType.setValue(SalesforceDatasetProperties.SourceType.SOQL_QUERY);
dataset.query.setValue("SELECT Id, Name FROM Account");
SalesforceInputDefinition input_def = new SalesforceInputDefinition();
SalesforceInputProperties input_props = (SalesforceInputProperties) input_def.createRuntimeProperties();
input_props.setDatasetProperties(dataset);
return input_props;
}
use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.
the class SalesforceInputTestIT method testTypeForModuleWithPickListType.
@Test
public void testTypeForModuleWithPickListType() 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", "Type"));
try (Reader reader = source.createReader(null)) {
int count = 3;
for (boolean available = reader.start(); available; available = reader.advance()) {
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertEquals(4, record.getSchema().getFields().size());
if ((count--) < 1) {
break;
}
}
}
}
Aggregations