Search in sources :

Example 46 with TSalesforceInputProperties

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());
}
Also used : Form(org.talend.daikon.properties.presentation.Form) TSalesforceInputDefinition(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputDefinition) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test)

Example 47 with TSalesforceInputProperties

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());
}
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)

Example 48 with TSalesforceInputProperties

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

Example 49 with TSalesforceInputProperties

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);
}
Also used : TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)

Example 50 with TSalesforceInputProperties

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);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) ArrayList(java.util.ArrayList) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)

Aggregations

TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)55 Test (org.junit.Test)32 IndexedRecord (org.apache.avro.generic.IndexedRecord)30 Schema (org.apache.avro.Schema)11 ArrayList (java.util.ArrayList)10 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)10 TSalesforceOutputProperties (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)9 TSalesforceOutputDefinition (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition)7 Result (org.talend.components.api.component.runtime.Result)6 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)5 IOException (java.io.IOException)4 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)4 Form (org.talend.daikon.properties.presentation.Form)4 PartnerConnection (com.sforce.soap.partner.PartnerConnection)3 LoginFault (com.sforce.soap.partner.fault.LoginFault)3 File (java.io.File)3 List (java.util.List)3 Ignore (org.junit.Ignore)3 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)3 TSalesforceInputDefinition (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputDefinition)3