use of org.talend.components.api.component.runtime.Writer in project components by Talend.
the class MarketoInputWriterTestIT method testGetMultipleLeadsLeadKeyWithEmailSOAPTDI39008.
@Test
public void testGetMultipleLeadsLeadKeyWithEmailSOAPTDI39008() throws Exception {
sink.initialize(null, propsSOAP);
Writer tmpWriter = sink.createWriteOperation().createWriter(null);
assertTrue(tmpWriter instanceof MarketoInputWriter);
MarketoInputWriter writer = (MarketoInputWriter) tmpWriter;
// create an input IndexedRecord
Schema s = SchemaBuilder.builder().record("input").fields().name("email").type().stringType().noDefault().endRecord();
IndexedRecord input = new GenericData.Record(s);
writer.open("SOAPTests");
input.put(0, "compdev@bj_talend.com");
writer.write(input);
input.put(0, "compqa@bj_talend.com");
writer.write(input);
writer.close();
assertEquals(2, writer.result.successCount);
}
use of org.talend.components.api.component.runtime.Writer in project components by Talend.
the class MarketoInputWriterTestIT method testGetMultipleLeadsLeadKeyWithEmailSOAP.
@Test
public void testGetMultipleLeadsLeadKeyWithEmailSOAP() throws Exception {
sink.initialize(null, propsSOAP);
Writer tmpWriter = sink.createWriteOperation().createWriter(null);
assertTrue(tmpWriter instanceof MarketoInputWriter);
MarketoInputWriter writer = (MarketoInputWriter) tmpWriter;
// create an input IndexedRecord
Schema s = SchemaBuilder.builder().record("input").fields().name("email").type().stringType().noDefault().name("dummy").type().stringType().noDefault().endRecord();
IndexedRecord input = new GenericData.Record(s);
input.put(0, "undx@undx.net");
input.put(1, "dummy value");
//
writer.open("SOAPTests");
writer.write(input);
List<IndexedRecord> successes = writer.getSuccessfulWrites();
assertNotNull(successes);
IndexedRecord record = successes.get(0);
assertNotNull(record);
LOG.debug("record = {}.", record);
Schema sout = record.getSchema();
assertEquals("Id", sout.getFields().get(0).name());
assertNotNull(record.get(0));
assertEquals("Email", sout.getFields().get(1).name());
assertNotNull(record.get(1));
assertEquals("ForeignSysPersonId", sout.getFields().get(2).name());
assertEquals("ForeignSysType", sout.getFields().get(3).name());
}
use of org.talend.components.api.component.runtime.Writer in project components by Talend.
the class SalesforceWriterTestIT method cleanupAllRecords.
@AfterClass
public static void cleanupAllRecords() throws NoSuchElementException, IOException {
List<IndexedRecord> recordsToClean = new ArrayList<>();
String prefixToDelete = UNIQUE_NAME + "_" + UNIQUE_ID;
// Get the list of records that match the prefix to delete.
{
TSalesforceInputProperties sfProps = getSalesforceInputProperties();
SalesforceTestBase.setupProps(sfProps.connection, false);
sfProps.module.setValue("moduleName", "Account");
sfProps.module.main.schema.setValue(SCHEMA_UPDATE_ACCOUNT);
DefaultComponentRuntimeContainerImpl container = new DefaultComponentRuntimeContainerImpl();
// Initialize the Source and Reader
SalesforceSource sfSource = new SalesforceSource();
sfSource.initialize(container, sfProps);
sfSource.validate(container);
int nameIndex = -1;
@SuppressWarnings("unchecked") Reader<IndexedRecord> sfReader = sfSource.createReader(container);
if (sfReader.start()) {
do {
IndexedRecord r = sfReader.getCurrent();
if (nameIndex == -1) {
nameIndex = r.getSchema().getField("Name").pos();
}
if (String.valueOf(r.get(nameIndex)).startsWith(prefixToDelete)) {
recordsToClean.add(r);
}
} while (sfReader.advance());
}
}
// Delete those records.
{
ComponentDefinition sfDef = new TSalesforceOutputDefinition();
TSalesforceOutputProperties sfProps = (TSalesforceOutputProperties) sfDef.createRuntimeProperties();
SalesforceTestBase.setupProps(sfProps.connection, false);
sfProps.outputAction.setValue(OutputAction.DELETE);
sfProps.module.setValue("moduleName", "Account");
sfProps.module.main.schema.setValue(SCHEMA_UPDATE_ACCOUNT);
DefaultComponentRuntimeContainerImpl container = new DefaultComponentRuntimeContainerImpl();
// Initialize the Sink, WriteOperation and Writer
SalesforceSink sfSink = new SalesforceSink();
sfSink.initialize(container, sfProps);
sfSink.validate(container);
SalesforceWriteOperation sfWriteOp = sfSink.createWriteOperation();
sfWriteOp.initialize(container);
Writer<Result> sfWriter = sfSink.createWriteOperation().createWriter(container);
sfWriter.open("uid1");
// Write one record.
for (IndexedRecord r : recordsToClean) {
sfWriter.write(r);
}
// Finish the Writer, WriteOperation and Sink.
Result wr1 = sfWriter.close();
sfWriteOp.finalize(Arrays.asList(wr1), container);
}
}
Aggregations