use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.
the class SalesforceComponentTestIT method testSchemaSerialized2.
@Test
public void testSchemaSerialized2() throws Throwable {
ComponentDefinition definition = getComponentService().getComponentDefinition(TSalesforceOutputDefinition.COMPONENT_NAME);
TSalesforceOutputProperties outputProps = (TSalesforceOutputProperties) getComponentService().getComponentProperties(TSalesforceOutputDefinition.COMPONENT_NAME);
Schema reject = SchemaBuilder.record("Reject").fields().name("A").type().stringType().noDefault().name("B").type().stringType().noDefault().endRecord();
Schema main = SchemaBuilder.record("Main").fields().name("C").type().stringType().noDefault().name("D").type().stringType().noDefault().endRecord();
outputProps.setValue("module.main.schema", main);
outputProps.setValue("schemaReject.schema", reject);
Schema main2 = (Schema) outputProps.getValuedProperty("module.main.schema").getValue();
Schema reject2 = (Schema) outputProps.getValuedProperty("schemaReject.schema").getValue();
assertEquals(main.toString(), main2.toString());
assertEquals(reject.toString(), reject2.toString());
String serialized = outputProps.toSerialized();
TSalesforceOutputProperties afterSerialized = Properties.Helper.fromSerializedPersistent(serialized, TSalesforceOutputProperties.class).object;
main2 = (Schema) afterSerialized.getValuedProperty("module.main.schema").getValue();
reject2 = (Schema) afterSerialized.getValuedProperty("schemaReject.schema").getValue();
assertEquals(main.toString(), main2.toString());
assertEquals(reject.toString(), reject2.toString());
}
use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.
the class SalesforceComponentTestIT method testSchemaSerialized.
@Test
public void testSchemaSerialized() throws Throwable {
// ComponentDefinition definition =
// getComponentService().getComponentDefinition(TSalesforceOutputDefinition.COMPONENT_NAME);
TSalesforceOutputProperties outputProps = (TSalesforceOutputProperties) getComponentService().getComponentProperties(TSalesforceOutputDefinition.COMPONENT_NAME);
Schema reject = SchemaBuilder.record("Reject").fields().name("A").type().stringType().noDefault().name("B").type().stringType().noDefault().endRecord();
Schema main = SchemaBuilder.record("Main").fields().name("C").type().stringType().noDefault().name("D").type().stringType().noDefault().endRecord();
assertEquals(2, outputProps.getAvailableConnectors(null, true).size());
for (Connector connector : outputProps.getAvailableConnectors(null, true)) {
if (connector.getName().equals(Connector.MAIN_NAME)) {
outputProps.setConnectedSchema(connector, main, true);
} else {
outputProps.setConnectedSchema(connector, reject, true);
}
}
String serialized = outputProps.toSerialized();
TSalesforceOutputProperties afterSerialized = Properties.Helper.fromSerializedPersistent(serialized, TSalesforceOutputProperties.class).object;
assertEquals(2, afterSerialized.getAvailableConnectors(null, true).size());
for (Connector connector : afterSerialized.getAvailableConnectors(null, true)) {
if (connector.getName().equals(Connector.MAIN_NAME)) {
Schema main2 = afterSerialized.getSchema(connector, true);
assertEquals(main.toString(), main2.toString());
} else {
Schema reject2 = afterSerialized.getSchema(connector, true);
assertEquals(reject.toString(), reject2.toString());
}
}
}
use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.
the class SalesforceTestBase method createSalesforceoutputProperties.
private static TSalesforceOutputProperties createSalesforceoutputProperties(String moduleName) throws Exception {
TSalesforceOutputProperties props = (TSalesforceOutputProperties) new TSalesforceOutputProperties("foo").init();
setupProps(props.connection, !ADD_QUOTES);
props.module.moduleName.setValue(moduleName);
// to setup schema.
props.module.afterModuleName();
return props;
}
use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.
the class SalesforceTestBase method deleteAllAccountTestRows.
public static void deleteAllAccountTestRows(String condition) throws Exception {
TSalesforceInputProperties properties = (TSalesforceInputProperties) new TSalesforceInputProperties("foo").init();
properties.condition.setValue("Name = '" + condition + "'");
BoundedReader<?> salesforceInputReader = new SalesforceTestBase().createSalesforceInputReaderFromModule(EXISTING_MODULE_NAME, properties);
// getting all rows
List<IndexedRecord> rows = new ArrayList<>();
try {
salesforceInputReader.start();
rows.add((IndexedRecord) salesforceInputReader.getCurrent());
while (salesforceInputReader.advance()) {
rows.add((IndexedRecord) salesforceInputReader.getCurrent());
}
} finally {
salesforceInputReader.close();
}
// filtering rows
TSalesforceOutputProperties salesforceoutputProperties = createSalesforceoutputProperties(EXISTING_MODULE_NAME);
setupProps(salesforceoutputProperties.connection, !ADD_QUOTES);
new SalesforceTestBase().deleteRows(rows, salesforceoutputProperties);
}
use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.
the class SalesforceTestBase method deleteRows.
protected void deleteRows(List<IndexedRecord> rows, SalesforceConnectionModuleProperties props) throws Exception {
// $NON-NLS-1$
TSalesforceOutputProperties deleteProperties = new TSalesforceOutputProperties("delete");
deleteProperties.copyValuesFrom(props);
deleteProperties.outputAction.setValue(OutputAction.DELETE);
LOGGER.debug("deleting " + rows.size() + " rows");
doWriteRows(deleteProperties, rows);
}
Aggregations