use of org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties in project components by Talend.
the class SalesforceBulkExecReaderTestIT method testOutputBulkExec.
/**
* This test for tSalesforceOutputBulk and tSalesforceBulkExec The runtime of tSalesforceOutputBulkExec should be
* work like this.
*/
private void testOutputBulkExec(int count) throws Throwable {
String random = createNewRandom();
List<IndexedRecord> rows = makeRows(random, count, false);
TSalesforceOutputBulkExecProperties outputBulkExecProperties = createAccountSalesforceOutputBulkExecProperties();
// Prepare the bulk file
TSalesforceOutputBulkProperties outputBulkProperties = (TSalesforceOutputBulkProperties) outputBulkExecProperties.getInputComponentProperties();
generateBulkFile(outputBulkProperties, rows);
// Test append
outputBulkProperties.append.setValue(true);
generateBulkFile(outputBulkProperties, rows);
// Execute the bulk action
TSalesforceBulkExecProperties bulkExecProperties = (TSalesforceBulkExecProperties) outputBulkExecProperties.getOutputComponentProperties();
try {
executeBulkInsert(bulkExecProperties, random, count * 2);
} finally {
// Delete the generated bulk file
delete(outputBulkProperties);
List<IndexedRecord> inputRows = readRows(bulkExecProperties);
List<IndexedRecord> allReadTestRows = filterAllTestRows(random, inputRows);
deleteRows(allReadTestRows, bulkExecProperties);
inputRows = readRows(bulkExecProperties);
assertEquals(0, filterAllTestRows(random, inputRows).size());
}
}
use of org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties in project components by Talend.
the class TSalesforceOutputBulkExecPropertiesTest method testGetInputComponentProperties.
@Test
public void testGetInputComponentProperties() {
properties.init();
TSalesforceOutputBulkProperties inputProperties = (TSalesforceOutputBulkProperties) properties.getInputComponentProperties();
assertEquals(properties.module.main.schema, inputProperties.schema.schema);
assertEquals(properties.module.main.schema.getValueEvaluator(), inputProperties.schema.schema.getValueEvaluator());
assertEquals(properties.bulkFilePath, inputProperties.bulkFilePath);
assertEquals(properties.bulkFilePath.getValueEvaluator(), inputProperties.bulkFilePath.getValueEvaluator());
assertEquals(properties.upsertRelationTable, inputProperties.upsertRelationTable);
assertEquals(properties.upsertRelationTable.columnName.getPossibleValues(), inputProperties.upsertRelationTable.columnName.getPossibleValues());
assertNotNull(inputProperties.getForm(Form.MAIN));
assertNotNull(inputProperties.getForm(Form.ADVANCED));
}
use of org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties in project components by Talend.
the class SalesforceRuntimeTestUtil method simulateUserBasicAction.
public TSalesforceOutputBulkProperties simulateUserBasicAction(TSalesforceOutputBulkDefinition definition, String data_file, Schema schema) {
// simulate some ui action
// user create component
// setup
TSalesforceOutputBulkProperties modelProperties = (TSalesforceOutputBulkProperties) definition.createProperties();
// the
// properties,
// trigger
// the
// setup
// layout
// and
// refresh
// layout
// user set the schema and file path
modelProperties.schema.schema.setValue(schema);
modelProperties.bulkFilePath.setValue(data_file);
// user switch the ui and trigger it
modelProperties.beforeUpsertRelationTable();
return modelProperties;
}
use of org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties in project components by Talend.
the class SalesforceRuntimeTestUtil method initWriter.
private Writer initWriter(TSalesforceOutputBulkDefinition definition, TSalesforceOutputBulkProperties modelProperties) throws IOException {
// simulate to generate the runtime code
TSalesforceOutputBulkProperties runtimeProperties = (TSalesforceOutputBulkProperties) definition.createRuntimeProperties();
// pass all the value from the ui model
runtimeProperties.schema.schema.setValue(modelProperties.schema.schema.getValue());
runtimeProperties.bulkFilePath.setValue(modelProperties.bulkFilePath.getStringValue());
runtimeProperties.append.setValue(modelProperties.append.getValue());
runtimeProperties.ignoreNull.setValue(modelProperties.ignoreNull.getValue());
Object obj = modelProperties.upsertRelationTable.columnName.getValue();
if (obj != null && obj instanceof List && !((List) obj).isEmpty()) {
runtimeProperties.upsertRelationTable.columnName.setValue(modelProperties.upsertRelationTable.columnName.getValue());
runtimeProperties.upsertRelationTable.lookupFieldExternalIdName.setValue(modelProperties.upsertRelationTable.lookupFieldExternalIdName.getValue());
runtimeProperties.upsertRelationTable.lookupFieldModuleName.setValue(modelProperties.upsertRelationTable.lookupFieldModuleName.getValue());
runtimeProperties.upsertRelationTable.lookupRelationshipFieldName.setValue(modelProperties.upsertRelationTable.lookupRelationshipFieldName.getValue());
runtimeProperties.upsertRelationTable.polymorphic.setValue(modelProperties.upsertRelationTable.polymorphic.getValue());
}
SourceOrSink source_sink = new SalesforceBulkFileSink();
source_sink.initialize(null, runtimeProperties);
ValidationResult result = source_sink.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
Sink sink = (Sink) source_sink;
WriteOperation writeOperation = sink.createWriteOperation();
writeOperation.initialize(null);
Writer writer = writeOperation.createWriter(null);
writer.open("component_instance_id");
return writer;
}
use of org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties in project components by Talend.
the class SalesforceBulkFileWriterTest method setup.
@Before
public void setup() {
TSalesforceOutputBulkProperties salesforceBulkProperties = new TSalesforceOutputBulkProperties("foo");
salesforceBulkProperties.outputAction.setValue(OutputAction.INSERT);
writer = new SalesforceBulkFileWriter(Mockito.mock(SalesforceBulkFileWriteOperation.class), salesforceBulkProperties, null);
}
Aggregations