use of org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties in project components by Talend.
the class SalesforceGetDeletedUpdatedReaderTestIT method runGetDeletedTest.
protected void runGetDeletedTest(boolean emptySchema) throws Throwable {
SalesforceGetDeletedUpdatedProperties sgduProperties = createSalesforceGetDeletedUpdatedProperties(emptySchema);
SalesforceConnectionModuleProperties connProperties = new SalesforceConnectionModuleProperties("foo") {
@Override
protected Set<PropertyPathConnector> getAllSchemaPropertiesConnectors(boolean isOutputConnection) {
// TODO Auto-generated method stub
return null;
}
};
connProperties.copyValuesFrom(sgduProperties);
SalesforceServerTimeStampReaderTestIT timeStampReaderTestIT = new SalesforceServerTimeStampReaderTestIT();
Calendar startDate = timeStampReaderTestIT.getServerTimestamp();
String randomInsert = createNewRandom();
int count = 10;
// Prepare test data
List<IndexedRecord> outputRowsInsert = makeRows(randomInsert, count, emptySchema);
outputRowsInsert = writeRows(randomInsert, connProperties, outputRowsInsert, SalesforceOutputProperties.OutputAction.INSERT);
checkRows(randomInsert, outputRowsInsert, count);
// Generate updated record
String randomUpdate = String.valueOf(Integer.parseInt(randomInsert) + 100);
List<IndexedRecord> outputRowsUpdate = makeUpdateRows(randomUpdate, emptySchema, outputRowsInsert);
outputRowsUpdate = writeRows(randomUpdate, connProperties, outputRowsUpdate, SalesforceOutputProperties.OutputAction.UPDATE);
checkRows(randomUpdate, outputRowsUpdate, count);
try {
List<IndexedRecord> rows = readRows(connProperties);
checkRows(randomUpdate, rows, count);
} finally {
deleteRows(outputRowsUpdate, connProperties);
}
Calendar endDate = timeStampReaderTestIT.getServerTimestamp();
// Long ms = 60000 - (endDate.getTimeInMillis() - startDate.getTimeInMillis());
// System.out.println(ms);
// if (ms > 0) {
// endDate.setTimeInMillis(startDate.getTimeInMillis()+120000);
// }
endDate.setTimeInMillis(endDate.getTimeInMillis() + 180000);
System.out.println(endDate.getTimeInMillis() - startDate.getTimeInMillis());
sgduProperties.startDate.setValue(startDate.getTime());
sgduProperties.endDate.setValue(endDate.getTime());
// Test get deleted records
TSalesforceGetDeletedProperties sgdProperties = new TSalesforceGetDeletedProperties("foo");
sgdProperties.copyValuesFrom(sgduProperties);
List<IndexedRecord> deletedRows = readDeletedUpdatedRows(sgdProperties);
checkRows(randomUpdate, deletedRows, count);
// Test get updated records (Can't be test here)
// (Can't be test here)
// TSalesforceGetUpdatedProperties sguProperties = (TSalesforceGetUpdatedProperties)new
// TSalesforceGetUpdatedProperties("foo").init();
// sgdProperties.copyValuesFrom(connProperties);
// List<IndexedRecord> updatedRows = readRows(sgdProperties);
// checkRows(randomUpdate, updatedRows, count);
}
use of org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties in project components by Talend.
the class SalesforceSource method createReader.
@Override
public BoundedReader createReader(RuntimeContainer adaptor) {
if (properties instanceof TSalesforceInputProperties) {
TSalesforceInputProperties sfInProperties = (TSalesforceInputProperties) properties;
boolean isBulk = TSalesforceInputProperties.QueryMode.Bulk.equals(sfInProperties.queryMode.getValue());
sfInProperties.connection.bulkConnection.setValue(isBulk);
if (isBulk) {
return new SalesforceBulkQueryInputReader(adaptor, this, sfInProperties);
} else {
return new SalesforceInputReader(adaptor, this, sfInProperties);
}
} else if (properties instanceof TSalesforceGetServerTimestampProperties) {
return new SalesforceServerTimeStampReader(adaptor, this, (TSalesforceGetServerTimestampProperties) properties);
} else if (properties instanceof TSalesforceGetDeletedProperties) {
return new SalesforceGetDeletedReader(adaptor, this, (TSalesforceGetDeletedProperties) properties);
} else if (properties instanceof TSalesforceGetUpdatedProperties) {
return new SalesforceGetUpdatedReader(adaptor, this, (TSalesforceGetUpdatedProperties) properties);
} else if (properties instanceof TSalesforceBulkExecProperties) {
((TSalesforceBulkExecProperties) properties).connection.bulkConnection.setValue(true);
return new SalesforceBulkExecReader(adaptor, this, (TSalesforceBulkExecProperties) properties);
}
return null;
}
Aggregations