use of org.talend.components.salesforce.runtime.SalesforceBulkFileSink 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;
}
Aggregations