Search in sources :

Example 41 with TSalesforceInputProperties

use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.

the class SalesforceConnectionMigrationTest method testSalesforceInputPropertiesMigration.

@Test
public void testSalesforceInputPropertiesMigration() throws IOException {
    Deserialized<TSalesforceInputProperties> deser = Properties.Helper.fromSerializedPersistent(TestUtils.getResourceAsString(getClass(), "tSalesforceInputProperties_621.json"), TSalesforceInputProperties.class);
    assertTrue("the property should be migrated, the migration returned false instead of true", deser.migrated);
    TSalesforceInputProperties properties = deser.object;
    String apiVersion = properties.connection.apiVersion.getValue();
    assertEquals("\"34.0\"", apiVersion);
}
Also used : TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) Test(org.junit.Test)

Example 42 with TSalesforceInputProperties

use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.

the class ConnectionPropertiesTest method testDeserializeOldReferenceProps.

@Test
public void testDeserializeOldReferenceProps() throws IOException {
    String oldPropsStr = TestUtils.getResourceAsString(getClass(), "tSalesforceInputConnectionProperties_old.json");
    SerializerDeserializer.Deserialized<TSalesforceInputProperties> fromSerializedPersistent = Properties.Helper.fromSerializedPersistent(oldPropsStr, TSalesforceInputProperties.class);
    TSalesforceInputProperties deserializedProps = fromSerializedPersistent.object;
    ComponentReferenceProperties deSerRefProps = (ComponentReferenceProperties) deserializedProps.getProperty("connection.referencedComponent");
    assertEquals("tSalesforceConnection", deSerRefProps.referenceDefinitionName.getValue());
    assertEquals("tSalesforceConnection_1", deSerRefProps.componentInstanceId.getValue());
    assertEquals(ComponentReferenceProperties.ReferenceType.COMPONENT_INSTANCE, deSerRefProps.referenceType.getValue());
}
Also used : SerializerDeserializer(org.talend.daikon.serialize.SerializerDeserializer) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) Test(org.junit.Test)

Example 43 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)

Example 44 with TSalesforceInputProperties

use of org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties in project components by Talend.

the class SalesforceTestBase method readRows.

protected List<IndexedRecord> readRows(SalesforceConnectionModuleProperties props) throws IOException {
    TSalesforceInputProperties inputProps = (TSalesforceInputProperties) new TSalesforceInputProperties("bar").init();
    inputProps.connection = props.connection;
    inputProps.module = props.module;
    inputProps.batchSize.setValue(200);
    inputProps.queryMode.setValue(TSalesforceInputProperties.QueryMode.Query);
    List<IndexedRecord> inputRows = readRows(inputProps);
    return inputRows;
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)

Example 45 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)

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