Search in sources :

Example 26 with TSalesforceOutputProperties

use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.

the class SalesforceComponentTestIT method testSchemaSerialized2.

@Test
public void testSchemaSerialized2() throws Throwable {
    ComponentDefinition definition = getComponentService().getComponentDefinition(TSalesforceOutputDefinition.COMPONENT_NAME);
    TSalesforceOutputProperties outputProps = (TSalesforceOutputProperties) getComponentService().getComponentProperties(TSalesforceOutputDefinition.COMPONENT_NAME);
    Schema reject = SchemaBuilder.record("Reject").fields().name("A").type().stringType().noDefault().name("B").type().stringType().noDefault().endRecord();
    Schema main = SchemaBuilder.record("Main").fields().name("C").type().stringType().noDefault().name("D").type().stringType().noDefault().endRecord();
    outputProps.setValue("module.main.schema", main);
    outputProps.setValue("schemaReject.schema", reject);
    Schema main2 = (Schema) outputProps.getValuedProperty("module.main.schema").getValue();
    Schema reject2 = (Schema) outputProps.getValuedProperty("schemaReject.schema").getValue();
    assertEquals(main.toString(), main2.toString());
    assertEquals(reject.toString(), reject2.toString());
    String serialized = outputProps.toSerialized();
    TSalesforceOutputProperties afterSerialized = Properties.Helper.fromSerializedPersistent(serialized, TSalesforceOutputProperties.class).object;
    main2 = (Schema) afterSerialized.getValuedProperty("module.main.schema").getValue();
    reject2 = (Schema) afterSerialized.getValuedProperty("schemaReject.schema").getValue();
    assertEquals(main.toString(), main2.toString());
    assertEquals(reject.toString(), reject2.toString());
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) Schema(org.apache.avro.Schema) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) Test(org.junit.Test)

Example 27 with TSalesforceOutputProperties

use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.

the class SalesforceComponentTestIT method testSchemaSerialized.

@Test
public void testSchemaSerialized() throws Throwable {
    // ComponentDefinition definition =
    // getComponentService().getComponentDefinition(TSalesforceOutputDefinition.COMPONENT_NAME);
    TSalesforceOutputProperties outputProps = (TSalesforceOutputProperties) getComponentService().getComponentProperties(TSalesforceOutputDefinition.COMPONENT_NAME);
    Schema reject = SchemaBuilder.record("Reject").fields().name("A").type().stringType().noDefault().name("B").type().stringType().noDefault().endRecord();
    Schema main = SchemaBuilder.record("Main").fields().name("C").type().stringType().noDefault().name("D").type().stringType().noDefault().endRecord();
    assertEquals(2, outputProps.getAvailableConnectors(null, true).size());
    for (Connector connector : outputProps.getAvailableConnectors(null, true)) {
        if (connector.getName().equals(Connector.MAIN_NAME)) {
            outputProps.setConnectedSchema(connector, main, true);
        } else {
            outputProps.setConnectedSchema(connector, reject, true);
        }
    }
    String serialized = outputProps.toSerialized();
    TSalesforceOutputProperties afterSerialized = Properties.Helper.fromSerializedPersistent(serialized, TSalesforceOutputProperties.class).object;
    assertEquals(2, afterSerialized.getAvailableConnectors(null, true).size());
    for (Connector connector : afterSerialized.getAvailableConnectors(null, true)) {
        if (connector.getName().equals(Connector.MAIN_NAME)) {
            Schema main2 = afterSerialized.getSchema(connector, true);
            assertEquals(main.toString(), main2.toString());
        } else {
            Schema reject2 = afterSerialized.getSchema(connector, true);
            assertEquals(reject.toString(), reject2.toString());
        }
    }
}
Also used : Connector(org.talend.components.api.component.Connector) TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) Schema(org.apache.avro.Schema) Test(org.junit.Test)

Example 28 with TSalesforceOutputProperties

use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.

the class SalesforceTestBase method createSalesforceoutputProperties.

private static TSalesforceOutputProperties createSalesforceoutputProperties(String moduleName) throws Exception {
    TSalesforceOutputProperties props = (TSalesforceOutputProperties) new TSalesforceOutputProperties("foo").init();
    setupProps(props.connection, !ADD_QUOTES);
    props.module.moduleName.setValue(moduleName);
    // to setup schema.
    props.module.afterModuleName();
    return props;
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)

Example 29 with TSalesforceOutputProperties

use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties 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 30 with TSalesforceOutputProperties

use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.

the class SalesforceTestBase method deleteRows.

protected void deleteRows(List<IndexedRecord> rows, SalesforceConnectionModuleProperties props) throws Exception {
    // $NON-NLS-1$
    TSalesforceOutputProperties deleteProperties = new TSalesforceOutputProperties("delete");
    deleteProperties.copyValuesFrom(props);
    deleteProperties.outputAction.setValue(OutputAction.DELETE);
    LOGGER.debug("deleting " + rows.size() + " rows");
    doWriteRows(deleteProperties, rows);
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)

Aggregations

TSalesforceOutputProperties (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)32 IndexedRecord (org.apache.avro.generic.IndexedRecord)18 Test (org.junit.Test)16 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)14 Result (org.talend.components.api.component.runtime.Result)13 TSalesforceOutputDefinition (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition)13 ArrayList (java.util.ArrayList)10 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)9 Schema (org.apache.avro.Schema)7 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)7 File (java.io.File)3 IOException (java.io.IOException)3 List (java.util.List)3 GenericData (org.apache.avro.generic.GenericData)3 Ignore (org.junit.Ignore)2 LoginFault (com.sforce.soap.partner.fault.LoginFault)1 NoSuchElementException (java.util.NoSuchElementException)1 AfterClass (org.junit.AfterClass)1 Before (org.junit.Before)1 Connector (org.talend.components.api.component.Connector)1