use of org.talend.components.salesforce.runtime.SalesforceSourceOrSink in project components by Talend.
the class SalesforceComponentTestIT method testUseExistingConnection.
@Test
public void testUseExistingConnection() throws Throwable {
SalesforceConnectionProperties connProps = (SalesforceConnectionProperties) getComponentService().getComponentProperties(TSalesforceConnectionDefinition.COMPONENT_NAME);
setupProps(connProps, !ADD_QUOTES);
final String currentComponentName = TSalesforceConnectionDefinition.COMPONENT_NAME + "_1";
RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {
@Override
public String getCurrentComponentId() {
return currentComponentName;
}
};
SalesforceSourceOrSink salesforceSourceOrSink = new SalesforceSourceOrSink();
salesforceSourceOrSink.initialize(connContainer, connProps);
assertEquals(ValidationResult.Result.OK, salesforceSourceOrSink.validate(connContainer).getStatus());
// Input component get connection from the tSalesforceConnection
ComponentDefinition inputDefinition = getComponentService().getComponentDefinition(TSalesforceInputDefinition.COMPONENT_NAME);
TSalesforceInputProperties inProps = (TSalesforceInputProperties) getComponentService().getComponentProperties(TSalesforceInputDefinition.COMPONENT_NAME);
inProps.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
SalesforceSourceOrSink salesforceInputSourceOrSink = new SalesforceSourceOrSink();
salesforceInputSourceOrSink.initialize(connContainer, inProps);
assertEquals(ValidationResult.Result.OK, salesforceInputSourceOrSink.validate(connContainer).getStatus());
}
use of org.talend.components.salesforce.runtime.SalesforceSourceOrSink 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());
}
Aggregations