Search in sources :

Example 1 with TSalesforceConnectionDefinition

use of org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition in project components by Talend.

the class SalesforceProxyTestIT method testProxy.

@Test
public void testProxy() {
    TSalesforceConnectionDefinition definition = (TSalesforceConnectionDefinition) getComponentService().getComponentDefinition(TSalesforceConnectionDefinition.COMPONENT_NAME);
    SalesforceConnectionProperties properties = (SalesforceConnectionProperties) definition.createRuntimeProperties();
    properties.bulkConnection.setValue(true);
    properties.userPassword.userId.setValue(userId);
    properties.userPassword.password.setValue(password);
    properties.userPassword.securityKey.setValue(securityKey);
    SourceOrSink sourceOrSink = new SalesforceSourceOrSink();
    sourceOrSink.initialize(null, properties);
    org.talend.daikon.properties.ValidationResult vr = sourceOrSink.validate(null);
    Assert.assertEquals(ValidationResult.Result.OK, vr.getStatus());
}
Also used : ValidationResult(org.talend.daikon.properties.ValidationResult) SourceOrSink(org.talend.components.api.component.runtime.SourceOrSink) SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) TSalesforceConnectionDefinition(org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition) Test(org.junit.Test)

Example 2 with TSalesforceConnectionDefinition

use of org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition in project components by Talend.

the class SalesforceComponentTestIT method testConnectionProps.

@Test
public void testConnectionProps() throws Throwable {
    SalesforceConnectionProperties props = (SalesforceConnectionProperties) new TSalesforceConnectionDefinition().createProperties();
    assertTrue(props.userPassword.userId.isRequired());
    assertTrue(props.userPassword.password.isRequired());
    assertFalse(props.userPassword.securityKey.isRequired());
    assertFalse(props.proxy.userPassword.userId.isRequired());
    assertFalse(props.proxy.userPassword.password.isRequired());
    Form mainForm = props.getForm(Form.MAIN);
    Form advancedForm = props.getForm(Form.ADVANCED);
    assertTrue(advancedForm.getWidget(props.reuseSession.getName()).isVisible());
    assertFalse(advancedForm.getWidget(props.sessionDirectory).isVisible());
    // Check "loginType" value changes influence "reuseSession"/"sessionDirectory" visible
    props.loginType.setValue(LoginType.OAuth);
    checkAndAfter(mainForm, "loginType", props);
    assertFalse(advancedForm.getWidget(props.reuseSession.getName()).isVisible());
    assertFalse(advancedForm.getWidget(props.sessionDirectory).isVisible());
    props.loginType.setValue(LoginType.Basic);
    checkAndAfter(mainForm, "loginType", props);
    assertTrue(advancedForm.getWidget(props.reuseSession.getName()).isVisible());
    assertFalse(advancedForm.getWidget(props.sessionDirectory).isVisible());
    // Check "bulkConnection" value changes influence "reuseSession"/"sessionDirectory" visible
    props.bulkConnection.setValue(true);
    checkAndAfter(advancedForm, "bulkConnection", props);
    assertFalse(advancedForm.getWidget(props.reuseSession.getName()).isVisible());
    assertFalse(advancedForm.getWidget(props.sessionDirectory).isVisible());
    props.bulkConnection.setValue(false);
    checkAndAfter(advancedForm, "bulkConnection", props);
    assertTrue(advancedForm.getWidget(props.reuseSession.getName()).isVisible());
    assertFalse(advancedForm.getWidget(props.sessionDirectory).isVisible());
    // Check "reuseSession" value changes influence "sessionDirectory" visible
    props.reuseSession.setValue(true);
    checkAndAfter(advancedForm, "reuseSession", props);
    assertTrue(advancedForm.getWidget(props.sessionDirectory).isVisible());
    props.reuseSession.setValue(false);
    checkAndAfter(advancedForm, "reuseSession", props);
    assertFalse(advancedForm.getWidget(props.sessionDirectory).isVisible());
}
Also used : SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) Form(org.talend.daikon.properties.presentation.Form) TSalesforceConnectionDefinition(org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition) Test(org.junit.Test)

Example 3 with TSalesforceConnectionDefinition

use of org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition in project components by Talend.

the class SalesforceComponentTestIT method testAfterLoginType.

@Test
public void testAfterLoginType() throws Throwable {
    ComponentProperties props;
    props = new TSalesforceConnectionDefinition().createProperties();
    ComponentTestUtils.checkSerialize(props, errorCollector);
    Property<LoginType> loginType = (Property<LoginType>) props.getProperty("loginType");
    LOGGER.debug(loginType.getPossibleValues().toString());
    assertEquals(SalesforceConnectionProperties.LoginType.Basic, loginType.getPossibleValues().get(0));
    assertEquals(SalesforceConnectionProperties.LoginType.OAuth, loginType.getPossibleValues().get(1));
    assertEquals(SalesforceConnectionProperties.LoginType.Basic, loginType.getValue());
    Form mainForm = props.getForm(Form.MAIN);
    assertEquals("Salesforce Connection Settings", mainForm.getTitle());
    assertFalse(mainForm.getWidget(SalesforceUserPasswordProperties.class).isHidden());
    loginType.setValue(SalesforceConnectionProperties.LoginType.OAuth);
    props = checkAndAfter(mainForm, "loginType", props);
    mainForm = props.getForm(Form.MAIN);
    assertTrue(mainForm.isRefreshUI());
    assertTrue(mainForm.getWidget(SalesforceUserPasswordProperties.class).isHidden());
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) TSalesforceConnectionDefinition(org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition) LoginType(org.talend.components.salesforce.SalesforceConnectionProperties.LoginType) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test)

Example 4 with TSalesforceConnectionDefinition

use of org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition in project components by Talend.

the class SalesforceComponentTestIT method testGetProps.

@Test
public void testGetProps() {
    ComponentProperties props = new TSalesforceConnectionDefinition().createProperties();
    Form f = props.getForm(Form.MAIN);
    ComponentTestUtils.checkSerialize(props, errorCollector);
    LOGGER.debug(f.toString());
    LOGGER.debug(props.toString());
    assertEquals(Form.MAIN, f.getName());
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) TSalesforceConnectionDefinition(org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 TSalesforceConnectionDefinition (org.talend.components.salesforce.tsalesforceconnection.TSalesforceConnectionDefinition)4 Form (org.talend.daikon.properties.presentation.Form)3 ComponentProperties (org.talend.components.api.properties.ComponentProperties)2 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)2 SourceOrSink (org.talend.components.api.component.runtime.SourceOrSink)1 LoginType (org.talend.components.salesforce.SalesforceConnectionProperties.LoginType)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1 Property (org.talend.daikon.properties.property.Property)1