use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceInputReaderTestIT method testClosingAlreadyClosedJob.
@Test
public void testClosingAlreadyClosedJob() {
try {
TSalesforceInputProperties properties = createTSalesforceInputProperties(false, true);
properties.manualQuery.setValue(false);
SalesforceBulkQueryInputReader reader = (SalesforceBulkQueryInputReader) this.<IndexedRecord>createBoundedReader(properties);
reader.start();
reader.close();
// Job could be closed on Salesforce side and previously we tried to close it again, we shouldn't do that.
// We can emulate this like calling close the job second time.
reader.close();
} catch (Throwable t) {
Assert.fail("This test shouldn't throw any errors, since we're closing already closed job");
}
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceInputReaderTestIT method testAggregrateQueryWithDoubleTypeAndBasicQuery.
@Test
public void testAggregrateQueryWithDoubleTypeAndBasicQuery() throws Throwable {
TSalesforceInputProperties props = createTSalesforceInputProperties(true, false);
props.manualQuery.setValue(true);
// alias is necessary and should be the same with schema
props.query.setValue("SELECT AVG(Amount) VALUE FROM Opportunity");
props.module.main.schema.setValue(SCHEMA_DOUBLE);
List<IndexedRecord> outputRows = readRows(props);
assertEquals(1, outputRows.size());
IndexedRecord record = outputRows.get(0);
assertNotNull(record.getSchema());
Object value = record.get(0);
Assert.assertTrue(value != null && value instanceof Double);
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceInputReaderTestIT method runInputTest.
protected void runInputTest(boolean emptySchema, boolean isBulkQury) throws Throwable {
TSalesforceInputProperties props = createTSalesforceInputProperties(emptySchema, isBulkQury);
String random = createNewRandom();
int count = 10;
// store rows in SF to retrieve them afterward to test the input.
List<IndexedRecord> outputRows = makeRows(random, count, true);
outputRows = writeRows(random, props, outputRows);
checkRows(random, outputRows, count);
try {
List<IndexedRecord> rows = readRows(props);
checkRows(random, rows, count);
testBulkQueryNullValue(props, random);
} finally {
deleteRows(outputRows, props);
}
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceInputReaderTestIT method testManualQueryDynamic.
public void testManualQueryDynamic(boolean isBulkQuery) throws Throwable {
TSalesforceInputProperties props = createTSalesforceInputProperties(true, false);
props.manualQuery.setValue(true);
props.query.setValue("select Id,IsDeleted,Name,Phone,CreatedDate from Account limit 1");
if (isBulkQuery) {
props.queryMode.setValue(TSalesforceInputProperties.QueryMode.Bulk);
}
List<IndexedRecord> outputRows = readRows(props);
assertEquals(1, outputRows.size());
IndexedRecord record = outputRows.get(0);
assertNotNull(record.getSchema());
Schema.Field field = record.getSchema().getField("CreatedDate");
assertEquals("yyyy-MM-dd'T'HH:mm:ss'.000Z'", field.getObjectProp(SchemaConstants.TALEND_COLUMN_PATTERN));
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceInputReaderTestIT method testDynamicFieldsOrder.
/*
* Test salesforce input manual query with dynamic return fields order same with SOQL fields order
*/
@Test
public void testDynamicFieldsOrder() throws Throwable {
TSalesforceInputProperties props = createTSalesforceInputProperties(true, false);
LOGGER.debug(props.module.main.schema.getStringValue());
props.manualQuery.setValue(true);
props.query.setValue("Select Name,IsDeleted,Id, Type,ParentId,MasterRecordId ,CreatedDate from Account order by CreatedDate limit 1 ");
List<IndexedRecord> rows = readRows(props);
assertEquals("No record returned!", 1, rows.size());
List<Schema.Field> fields = rows.get(0).getSchema().getFields();
assertEquals(7, fields.size());
assertEquals("Name", fields.get(0).name());
assertEquals("IsDeleted", fields.get(1).name());
assertEquals("Id", fields.get(2).name());
assertEquals("Type", fields.get(3).name());
assertEquals("ParentId", fields.get(4).name());
assertEquals("MasterRecordId", fields.get(5).name());
assertEquals("CreatedDate", fields.get(6).name());
}
Aggregations