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