Search in sources :

Example 1 with TSalesforceOutputProperties

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

the class SalesforceGetDeletedUpdatedReaderTestIT method writeRows.

protected List<IndexedRecord> writeRows(String random, SalesforceConnectionModuleProperties props, List<IndexedRecord> outputRows, TSalesforceOutputProperties.OutputAction action) throws Exception {
    // $NON-NLS-1$
    TSalesforceOutputProperties outputProps = new TSalesforceOutputProperties("output");
    outputProps.copyValuesFrom(props);
    outputProps.outputAction.setValue(action);
    outputProps.ignoreNull.setValue(true);
    doWriteRows(outputProps, outputRows);
    List<IndexedRecord> inputRows = readRows(props);
    return checkRows(random, inputRows, outputRows.size());
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord)

Example 2 with TSalesforceOutputProperties

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

the class SalesforceComponentTestIT method testOutputActionType.

@Test
public void testOutputActionType() throws Throwable {
    ComponentDefinition definition = getComponentService().getComponentDefinition(TSalesforceOutputDefinition.COMPONENT_NAME);
    TSalesforceOutputProperties outputProps = (TSalesforceOutputProperties) getComponentService().getComponentProperties(TSalesforceOutputDefinition.COMPONENT_NAME);
    setupProps(outputProps.connection, !ADD_QUOTES);
    outputProps.outputAction.setValue(OutputAction.DELETE);
    setupModule(outputProps.module, "Account");
    ComponentTestUtils.checkSerialize(outputProps, errorCollector);
    List<IndexedRecord> rows = new ArrayList<>();
    try {
        writeRows(null, outputProps, rows);
    } catch (Exception ex) {
        if (ex instanceof ClassCastException) {
            LOGGER.debug("Exception: " + ex.getMessage());
            fail("Get error before delete!");
        }
    }
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) ArrayList(java.util.ArrayList) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) Test(org.junit.Test)

Example 3 with TSalesforceOutputProperties

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

the class SalesforceTestBase method writeRows.

protected static void writeRows(List<IndexedRecord> outputRows) throws Exception {
    // $NON-NLS-1$
    TSalesforceOutputProperties outputProps = createSalesforceoutputProperties(EXISTING_MODULE_NAME);
    outputProps.outputAction.setValue(TSalesforceOutputProperties.OutputAction.INSERT);
    doWriteRows(outputProps, outputRows);
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)

Example 4 with TSalesforceOutputProperties

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

the class SalesforceWriteOperationTest method setUp.

@Before
public void setUp() {
    properties = new TSalesforceOutputProperties("root");
    sink = new SalesforceSink();
    writeOperation = new SalesforceWriteOperation(sink);
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) SalesforceWriteOperation(org.talend.components.salesforce.runtime.SalesforceWriteOperation) SalesforceSink(org.talend.components.salesforce.runtime.SalesforceSink) Before(org.junit.Before)

Example 5 with TSalesforceOutputProperties

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

the class SalesforceSchemaTest method testOutputSchemaForTSalesforceOutput1.

@Test
public void testOutputSchemaForTSalesforceOutput1() throws Throwable {
    TSalesforceOutputDefinition defin = (TSalesforceOutputDefinition) getComponentService().getComponentDefinition(TSalesforceOutputDefinition.COMPONENT_NAME);
    TSalesforceOutputProperties modelProps = (TSalesforceOutputProperties) defin.createProperties();
    modelProps.module.main.schema.setValue(schema);
    modelProps.extendInsert.setValue(false);
    modelProps.retrieveInsertId.setValue(true);
    modelProps.outputAction.setValue(OutputAction.INSERT);
    getComponentService().afterProperty("schema", modelProps.module.main);
    Schema output = modelProps.schemaFlow.schema.getValue();
    assertThat(output.getType(), is(Schema.Type.RECORD));
    assertThat(output.getFields(), hasSize(4));
    assertThat(output.getFields().get(0).name(), is("col_1"));
    assertThat(output.getFields().get(0).schema().getType(), is(Schema.Type.STRING));
    assertThat(output.getFields().get(1).name(), is("col_2"));
    assertThat(output.getFields().get(1).schema().getType(), is(Schema.Type.INT));
    assertThat(output.getFields().get(2).name(), is("col_3"));
    assertThat(output.getFields().get(2).schema().getType(), is(Schema.Type.LONG));
    assertThat(output.getFields().get(2).getProp(SchemaConstants.TALEND_COLUMN_PATTERN), is("yyyy-MM-dd'T'HH:mm:ss'.000Z'"));
    assertThat(output.getFields().get(3).name(), is("salesforce_id"));
    assertThat(output.getFields().get(3).schema().getType(), is(Schema.Type.STRING));
    Schema reject = modelProps.schemaReject.schema.getValue();
    assertThat(reject.getType(), is(Schema.Type.RECORD));
    assertThat(reject.getFields(), hasSize(6));
    assertThat(reject.getFields().get(0).name(), is("col_1"));
    assertThat(reject.getFields().get(0).schema().getType(), is(Schema.Type.STRING));
    assertThat(reject.getFields().get(1).name(), is("col_2"));
    assertThat(reject.getFields().get(1).schema().getType(), is(Schema.Type.INT));
    assertThat(reject.getFields().get(2).name(), is("col_3"));
    assertThat(reject.getFields().get(2).schema().getType(), is(Schema.Type.LONG));
    assertThat(reject.getFields().get(2).getProp(SchemaConstants.TALEND_COLUMN_PATTERN), is("yyyy-MM-dd'T'HH:mm:ss'.000Z'"));
    assertThat(reject.getFields().get(3).name(), is("errorCode"));
    assertThat(reject.getFields().get(3).schema().getType(), is(Schema.Type.STRING));
    assertThat(reject.getFields().get(4).name(), is("errorFields"));
    assertThat(reject.getFields().get(4).schema().getType(), is(Schema.Type.STRING));
    assertThat(reject.getFields().get(5).name(), is("errorMessage"));
    assertThat(reject.getFields().get(5).schema().getType(), is(Schema.Type.STRING));
}
Also used : TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) Schema(org.apache.avro.Schema) TSalesforceOutputDefinition(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition) Test(org.junit.Test)

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