use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceComponentTestIT method testInputProps.
@Test
public void testInputProps() throws Throwable {
TSalesforceInputProperties props = (TSalesforceInputProperties) new TSalesforceInputDefinition().createProperties();
assertEquals(2, props.queryMode.getPossibleValues().size());
Property[] returns = new TSalesforceInputDefinition().getReturnProperties();
assertEquals(ComponentDefinition.RETURN_TOTAL_RECORD_COUNT, returns[1].getName());
// Default query mode
Form queryAdvancedForm = props.getForm(Form.ADVANCED);
assertTrue(queryAdvancedForm.getChildForm(props.connection.getName()).getWidget(props.connection.bulkConnection.getName()).isHidden());
assertFalse(queryAdvancedForm.getWidget(props.normalizeDelimiter.getName()).isHidden());
assertFalse(queryAdvancedForm.getWidget(props.columnNameDelimiter.getName()).isHidden());
assertFalse(queryAdvancedForm.getChildForm(props.connection.getName()).getWidget(props.connection.httpChunked.getName()).isHidden());
assertTrue(queryAdvancedForm.getChildForm(props.connection.getName()).getWidget(props.connection.httpTraceMessage.getName()).isHidden());
// Change to bulk query mode
props.queryMode.setValue(TSalesforceInputProperties.QueryMode.Bulk);
props.afterQueryMode();
Form bulkQueryAdvancedForm = props.getForm(Form.ADVANCED);
assertTrue(bulkQueryAdvancedForm.getWidget(props.normalizeDelimiter.getName()).isHidden());
assertTrue(bulkQueryAdvancedForm.getWidget(props.columnNameDelimiter.getName()).isHidden());
assertTrue(bulkQueryAdvancedForm.getChildForm(props.connection.getName()).getWidget(props.connection.httpChunked.getName()).isHidden());
assertFalse(bulkQueryAdvancedForm.getChildForm(props.connection.getName()).getWidget(props.connection.httpTraceMessage.getName()).isHidden());
assertTrue(bulkQueryAdvancedForm.getChildForm(props.connection.getName()).getWidget(props.connection.bulkConnection.getName()).isHidden());
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceComponentTestIT method testInputConnectionRef.
/*
* If the logic changes for this test please specify appropriate timeout.
* The average execution time for this test 1.4-1.9 sec.
*/
@Test(timeout = 30_000)
public void testInputConnectionRef() throws Throwable {
ComponentDefinition definition = getComponentService().getComponentDefinition(TSalesforceInputDefinition.COMPONENT_NAME);
TSalesforceInputProperties props = (TSalesforceInputProperties) getComponentService().getComponentProperties(TSalesforceInputDefinition.COMPONENT_NAME);
setupProps(props.connection, !ADD_QUOTES);
SalesforceSourceOrSink salesforceSourceOrSink = new SalesforceSourceOrSink();
salesforceSourceOrSink.initialize(null, props);
assertEquals(ValidationResult.Result.OK, salesforceSourceOrSink.validate(null).getStatus());
// Referenced properties simulating salesforce connect component
SalesforceConnectionProperties cProps = (SalesforceConnectionProperties) getComponentService().getComponentProperties(TSalesforceConnectionDefinition.COMPONENT_NAME);
setupProps(cProps, !ADD_QUOTES);
cProps.userPassword.password.setValue("xxx");
String compId = "comp1";
// Use the connection props of the salesforce connect component
props.connection.referencedComponent.referenceType.setValue(ComponentReferenceProperties.ReferenceType.COMPONENT_INSTANCE);
props.connection.referencedComponent.componentInstanceId.setValue(compId);
props.connection.referencedComponent.setReference(cProps);
checkAndAfter(props.connection.getForm(Form.REFERENCE), "referencedComponent", props.connection);
salesforceSourceOrSink = new SalesforceSourceOrSink();
salesforceSourceOrSink.initialize(null, props);
salesforceSourceOrSink.validate(null);
assertEquals(ValidationResult.Result.ERROR, salesforceSourceOrSink.validate(null).getStatus());
// Back to using the connection props of the salesforce input component
props.connection.referencedComponent.referenceType.setValue(ComponentReferenceProperties.ReferenceType.THIS_COMPONENT);
props.connection.referencedComponent.componentInstanceId.setValue(null);
props.connection.referencedComponent.setReference(null);
// Check that the null referenced component works.
checkAndAfter(props.connection.getForm(Form.REFERENCE), "referencedComponent", props.connection);
salesforceSourceOrSink = new SalesforceSourceOrSink();
salesforceSourceOrSink.initialize(null, props);
salesforceSourceOrSink.validate(null);
assertEquals(ValidationResult.Result.OK, salesforceSourceOrSink.validate(null).getStatus());
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceInputPropertiesMigrationTaskTest method testSafetySwitch.
@Test
public void testSafetySwitch() throws IOException {
// Loading old SalesforceInput properties and check if value was initialized correctly.
Deserialized<TSalesforceInputProperties> deser = Properties.Helper.fromSerializedPersistent(TestUtils.getResourceAsString(getClass(), "tSalesforceInputProperties_701.json"), TSalesforceInputProperties.class);
TSalesforceInputProperties properties = deser.object;
assertTrue(properties.safetySwitch.getValue());
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.
the class SalesforceTestBase method createSalesforceInputReaderFromModule.
public <T> BoundedReader<T> createSalesforceInputReaderFromModule(String moduleName, TSalesforceInputProperties properties) {
if (null == properties) {
// $NON-NLS-1$
properties = (TSalesforceInputProperties) new TSalesforceInputProperties("foo").init();
}
setupProps(properties.connection, !ADD_QUOTES);
properties.batchSize.setValue(200);
properties.module.moduleName.setValue(moduleName);
properties.module.main.schema.setValue(SchemaBuilder.builder().record("test").prop(SchemaConstants.INCLUDE_ALL_FIELDS, "true").fields().endRecord());
return createBoundedReader(properties);
}
use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties 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);
}
Aggregations