Search in sources :

Example 1 with SalesforceSourceOrSink

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());
}
Also used : SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) SalesforceSourceOrSink(org.talend.components.salesforce.runtime.SalesforceSourceOrSink) DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) Test(org.junit.Test)

Example 2 with SalesforceSourceOrSink

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());
}
Also used : SalesforceSourceOrSink(org.talend.components.salesforce.runtime.SalesforceSourceOrSink) SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)2 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)2 SalesforceSourceOrSink (org.talend.components.salesforce.runtime.SalesforceSourceOrSink)2 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)2 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)1 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)1