Search in sources :

Example 31 with Result

use of org.talend.components.api.component.runtime.Result in project components by Talend.

the class JiraWriteOperationTest method testFinalize.

/**
 * Checks {@link JiraWriteOperation#finalize()} computes total of output results
 */
@Test
public void testFinalize() {
    Result result1 = new Result("id-1", 15, 10, 5);
    Result result2 = new Result("id-1", 25, 20, 5);
    List<Result> results = Arrays.asList(result1, result2);
    JiraWriteOperation writeOperation = new JiraWriteOperation(sink);
    Map<String, Object> returnValues = writeOperation.finalize(results, container);
    assertEquals(40, returnValues.get(ComponentDefinition.RETURN_TOTAL_RECORD_COUNT));
    assertEquals(30, returnValues.get(ComponentDefinition.RETURN_SUCCESS_RECORD_COUNT));
    assertEquals(10, returnValues.get(ComponentDefinition.RETURN_REJECT_RECORD_COUNT));
}
Also used : Result(org.talend.components.api.component.runtime.Result) Test(org.junit.Test)

Example 32 with Result

use of org.talend.components.api.component.runtime.Result in project components by Talend.

the class JiraWriter method open.

/**
 * Initializes connection of this {@link Writer}
 *
 * @param uId Unique ID of this {@link Writer}
 */
@Override
public void open(String uId) {
    if (opened) {
        LOG.debug("Writer is already opened");
        return;
    }
    result = new Result(uId);
    String hostPort = writeOperation.getSink().getHostPort();
    String userId = writeOperation.getSink().getUserId();
    String userPassword = writeOperation.getSink().getUserPassword();
    rest = new Rest(hostPort);
    rest.setCredentials(userId, userPassword);
    opened = true;
}
Also used : Rest(org.talend.components.jira.connection.Rest) Result(org.talend.components.api.component.runtime.Result)

Example 33 with Result

use of org.talend.components.api.component.runtime.Result in project components by Talend.

the class FileDelimitedTestBasic method doWriteRows.

// Returns the rows written (having been re-read so they have their Ids)
protected Result doWriteRows(TFileOutputDelimitedProperties props, List<IndexedRecord> outputRows) throws Exception {
    FileDelimitedSink sink = new FileDelimitedSink();
    sink.initialize(adaptor, props);
    sink.validate(adaptor);
    FileDelimitedWriteOperation writeOperation = sink.createWriteOperation();
    FileDelimitedWriter delimitedWriter = writeOperation.createWriter(adaptor);
    Result result;
    delimitedWriter.open("foo");
    try {
        for (IndexedRecord row : outputRows) {
            delimitedWriter.write(row);
        }
    } finally {
        result = delimitedWriter.close();
    }
    return result;
}
Also used : FileDelimitedWriter(org.talend.components.filedelimited.runtime.FileDelimitedWriter) IndexedRecord(org.apache.avro.generic.IndexedRecord) FileDelimitedWriteOperation(org.talend.components.filedelimited.runtime.FileDelimitedWriteOperation) FileDelimitedSink(org.talend.components.filedelimited.runtime.FileDelimitedSink) ValidationResult(org.talend.daikon.properties.ValidationResult) Result(org.talend.components.api.component.runtime.Result)

Example 34 with Result

use of org.talend.components.api.component.runtime.Result in project components by Talend.

the class FileDelimitedWriterTestIT method basicOutputTest.

protected void basicOutputTest(TFileOutputDelimitedProperties properties, String refFilePath) throws Throwable {
    String fileName = properties.fileName.getStringValue();
    if (properties.targetIsStream.getValue()) {
        properties.fileName.setValue(new FileOutputStream(new File(fileName)));
    }
    List<IndexedRecord> records = generateRecords(25);
    Result result = doWriteRows(properties, records);
    assertEquals(25, result.getTotalCount());
    String outputFile = fileName;
    if (properties.compress.getValue()) {
        outputFile = outputFile.substring(0, outputFile.lastIndexOf(".")) + ".zip";
    }
    assertTrue(FileRuntimeHelper.compareInTextMode(outputFile, refFilePath, getEncoding(properties.encoding)));
    // Need to close the stream firstly. then
    if (properties.targetIsStream.getValue()) {
        ((FileOutputStream) properties.fileName.getValue()).close();
    }
    assertTrue(deleteFile(fileName));
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Result(org.talend.components.api.component.runtime.Result)

Example 35 with Result

use of org.talend.components.api.component.runtime.Result in project components by Talend.

the class MarketoInputReader method getReturnValues.

@Override
public Map<String, Object> getReturnValues() {
    Result result = new Result();
    Map<String, Object> res = result.toMap();
    res.put(RETURN_NB_CALL, apiCalls);
    res.put(RETURN_ERROR_MESSAGE, errorMessage);
    return res;
}
Also used : MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Result(org.talend.components.api.component.runtime.Result)

Aggregations

Result (org.talend.components.api.component.runtime.Result)76 Test (org.junit.Test)42 IndexedRecord (org.apache.avro.generic.IndexedRecord)31 ArrayList (java.util.ArrayList)22 Schema (org.apache.avro.Schema)17 TSalesforceOutputProperties (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)13 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)11 TSalesforceOutputDefinition (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition)11 IOException (java.io.IOException)10 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)8 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)8 NetSuiteSink (org.talend.components.netsuite.NetSuiteSink)8 NetSuiteOutputWriter (org.talend.components.netsuite.output.NetSuiteOutputWriter)8 NetSuiteWriteOperation (org.talend.components.netsuite.output.NetSuiteWriteOperation)8 ValidationResult (org.talend.daikon.properties.ValidationResult)7 NetSuitePortType (com.netsuite.webservices.v2016_2.platform.NetSuitePortType)6 SQLException (java.sql.SQLException)6 List (java.util.List)6 NetSuiteRuntimeImpl (org.talend.components.netsuite.v2016_2.NetSuiteRuntimeImpl)6 NetSuiteSinkImpl (org.talend.components.netsuite.v2016_2.NetSuiteSinkImpl)6