use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testDescribeFields.
@Test
public void testDescribeFields() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, irProps);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
List<Field> fieldList = client.getAllLeadFields();
assertTrue(fieldList.size() > 500);
for (Field f : fieldList) {
// LOG.debug("f [{}] = {} {}.", f.doc(), f, f.getObjectProps());
assertNotNull(f.doc());
assertNotNull(f.schema().getType());
}
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientBulkExecTestIT method testBulkExecCustomObject.
@Test
public void testBulkExecCustomObject() throws Exception {
props.bulkImportTo.setValue(BulkImportTo.CustomObjects);
props.customObjectName.setValue("car_c");
props.bulkFilePath.setValue(coCSV);
props.logDownloadPath.setValue(downloadPath);
props.pollWaitTime.setValue(5);
props.afterBulkImportTo();
Schema s = MarketoConstants.getBulkImportCustomObjectSchema();
MarketoSource source = new MarketoSource();
source.initialize(null, props);
assertEquals(Result.OK, source.validate(null).getStatus());
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
MarketoRecordResult result = client.bulkImport(props);
assertTrue(result.isSuccess());
assertEquals(1, result.getRecordCount());
IndexedRecord r = result.getRecords().get(0);
assertNotNull(r);
assertEquals(1, r.get(s.getField("numOfObjectsProcessed").pos()));
assertEquals(2, r.get(s.getField("numOfRowsFailed").pos()));
assertEquals(0, r.get(s.getField("numOfRowsWithWarning").pos()));
assertEquals("car_c", r.get(s.getField("objectApiName").pos()));
assertEquals("import", r.get(s.getField("operation").pos()));
assertEquals("Complete", r.get(s.getField("status").pos()));
Object batchId = r.get(s.getField("batchId").pos());
assertNotNull(batchId);
Path logf = Paths.get(downloadPath, String.format("bulk_customobjects_car_c_%d_failures.csv", Integer.valueOf(batchId.toString())));
assertEquals(logf.toString(), r.get(s.getField("failuresLogFile").pos()));
assertTrue(Files.exists(logf));
assertEquals(216, Files.readAllBytes(logf).length);
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientBulkExecTestIT method testBulkExecLead.
@Test
public void testBulkExecLead() throws Exception {
props.bulkImportTo.setValue(BulkImportTo.Leads);
props.bulkFilePath.setValue(leadCSV);
props.logDownloadPath.setValue(downloadPath);
props.pollWaitTime.setValue(1);
props.afterBulkImportTo();
Schema s = MarketoConstants.getBulkImportLeadSchema();
MarketoSource source = new MarketoSource();
source.initialize(null, props);
assertEquals(Result.OK, source.validate(null).getStatus());
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
MarketoRecordResult result = client.bulkImport(props);
assertTrue(result.isSuccess());
assertEquals(1, result.getRecordCount());
IndexedRecord r = result.getRecords().get(0);
assertNotNull(r);
assertEquals(2, r.get(s.getField("numOfLeadsProcessed").pos()));
assertEquals(0, r.get(s.getField("numOfRowsFailed").pos()));
assertEquals(1, r.get(s.getField("numOfRowsWithWarning").pos()));
assertEquals("Complete", r.get(s.getField("status").pos()));
Object batchId = r.get(s.getField("batchId").pos());
assertNotNull(batchId);
Path logf = Paths.get(downloadPath, String.format("bulk_leads_%d_warnings.csv", Integer.valueOf(batchId.toString())));
assertEquals(logf.toString(), r.get(s.getField("warningsLogFile").pos()));
assertTrue(Files.exists(logf));
assertEquals(86, Files.readAllBytes(logf).length);
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoSOAPClientTestIT method testAddToList.
/*
*
*
* ListOperations
*
*
*/
@Test
public void testAddToList() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, listProperties);
MarketoClientService client = source.getClientService(null);
//
ListOperationParameters parms = new ListOperationParameters();
parms.setApiMode(SOAP.name());
parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
parms.setLeadKeyValue(new String[] { createdLeads.get(10).toString() });
// first make sure to remove lead
MarketoSyncResult result = client.removeFromList(parms);
LOG.debug("result = {}.", result);
List<SyncStatus> changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
LOG.debug("r = {}.", r);
}
// then add it
result = client.addToList(parms);
LOG.debug("result = {}.", result);
changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertTrue(Boolean.parseBoolean(r.getStatus()));
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoSOAPClientTestIT method testGetLeadFailWrongHost.
@Test(expected = IOException.class)
public void testGetLeadFailWrongHost() throws Exception {
inputProperties.inputOperation.setValue(getLead);
inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
inputProperties.connection.endpoint.setValue(ENDPOINT_URL_INEXISTANT);
inputProperties.afterInputOperation();
//
inputProperties.leadKeyValue.setValue(EMAIL_INEXISTANT);
MarketoSource source = new MarketoSource();
source.initialize(null, inputProperties);
MarketoClientService client = source.getClientService(null);
//
MarketoRecordResult result = client.getLead(inputProperties, null);
List<IndexedRecord> records = result.getRecords();
assertEquals(emptyList(), records);
LOG.debug("record = " + records);
}
Aggregations