Search in sources :

Example 1 with SalesforceGetDeletedUpdatedProperties

use of org.talend.components.salesforce.SalesforceGetDeletedUpdatedProperties 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);
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) IndexedRecord(org.apache.avro.generic.IndexedRecord) TSalesforceGetDeletedProperties(org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties) Calendar(java.util.Calendar) SalesforceGetDeletedUpdatedProperties(org.talend.components.salesforce.SalesforceGetDeletedUpdatedProperties) SalesforceConnectionModuleProperties(org.talend.components.salesforce.SalesforceConnectionModuleProperties)

Example 2 with SalesforceGetDeletedUpdatedProperties

use of org.talend.components.salesforce.SalesforceGetDeletedUpdatedProperties in project components by Talend.

the class SalesforceGetDeletedUpdatedReaderTestIT method createSalesforceGetDeletedUpdatedProperties.

protected SalesforceGetDeletedUpdatedProperties createSalesforceGetDeletedUpdatedProperties(boolean emptySchema) throws Throwable {
    SalesforceGetDeletedUpdatedProperties props = (SalesforceGetDeletedUpdatedProperties) new SalesforceGetDeletedUpdatedProperties("foo").init();
    props.connection.timeout.setValue(120000);
    setupProps(props.connection, !ADD_QUOTES);
    if (emptySchema) {
        setupModuleWithEmptySchema(props.module, EXISTING_MODULE_NAME);
    } else {
        props.module.moduleName.setValue(EXISTING_MODULE_NAME);
        props.module.main.schema.setValue(getMakeRowSchema(false));
    }
    props.startDate.setValue(Calendar.getInstance().getTime());
    props.endDate.setValue(Calendar.getInstance().getTime());
    ComponentTestUtils.checkSerialize(props, errorCollector);
    return props;
}
Also used : SalesforceGetDeletedUpdatedProperties(org.talend.components.salesforce.SalesforceGetDeletedUpdatedProperties)

Aggregations

SalesforceGetDeletedUpdatedProperties (org.talend.components.salesforce.SalesforceGetDeletedUpdatedProperties)2 Calendar (java.util.Calendar)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)1 SalesforceConnectionModuleProperties (org.talend.components.salesforce.SalesforceConnectionModuleProperties)1 TSalesforceGetDeletedProperties (org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties)1