use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testGetCustomObjectWithCompoundKey.
@Test
public void testGetCustomObjectWithCompoundKey() throws Exception {
irProps.customObjectAction.setValue(CustomObjectAction.get);
irProps.customObjectName.setValue(TEST_CO_NAME_CAR);
irProps.validateFetchCustomObjectSchema();
irProps.useCompoundKey.setValue(true);
// "searchableFields": "[[\"customerId\",\"VIN\"],[\"marketoGUID\"],[\"customerId\"]]"
irProps.compoundKey.keyName.setValue(Arrays.asList("customerId", "VIN"));
// WBA4R7C55HK895912
irProps.compoundKey.keyValue.setValue(Arrays.asList("4137181", "WBA4R7C30HK896061"));
MarketoSource source = new MarketoSource();
source.initialize(null, irProps);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
MarketoRecordResult result = client.getCustomObjects(irProps, null);
LOG.debug("result = {}.", result);
assertNotNull(result.getRecords());
assertEquals(1, result.getRecords().size());
IndexedRecord record = result.getRecords().get(0);
Schema s = record.getSchema();
assertEquals(4137181, record.get(s.getField("customerId").pos()));
assertEquals("WBA4R7C30HK896061", record.get(s.getField("VIN").pos()));
assertEquals("FIT", record.get(s.getField("brand").pos()));
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method createCustomObjectRecords.
public MarketoSyncResult createCustomObjectRecords(String dedupeBy) throws Exception {
oprops.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
oprops.customObjectSyncAction.setValue(CustomObjectSyncAction.createOrUpdate);
oprops.customObjectDedupeBy.setValue(dedupeBy);
Schema s = //
SchemaBuilder.record("sn").fields().name(FIELD_CO_SMARTPHONE_BRAND).type().stringType().noDefault().name(FIELD_CO_SMARTPHONE_MODEL).type().stringType().noDefault().name(FIELD_CO_SMARTPHONE_CUSTOMER_ID).type().intType().noDefault().endRecord();
List<IndexedRecord> records = new ArrayList<>();
IndexedRecord r1;
for (String m : TEST_SMARTPHONE_MODELS) {
r1 = new Record(s);
r1.put(0, TEST_SMARTPHONE_BRAND_SAMSUNG);
r1.put(1, m);
r1.put(2, 3113479);
records.add(r1);
}
MarketoSource source = new MarketoSource();
source.initialize(null, irProps);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
MarketoSyncResult rs = client.syncCustomObjects(oprops, records);
return rs;
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientBulkExecTestIT method testBulkExecValidate.
@Test
public void testBulkExecValidate() throws Exception {
props.bulkImportTo.setValue(BulkImportTo.Leads);
props.bulkFilePath.setValue(leadCSV);
props.logDownloadPath.setValue("/Users/undx/mp/");
props.pollWaitTime.setValue(1);
props.connection.apiMode.setValue(APIMode.SOAP);
props.connection.endpoint.setValue(ENDPOINT_SOAP);
props.connection.clientAccessId.setValue(USERID_SOAP);
props.connection.secretKey.setValue(SECRETKEY_SOAP);
props.connection.afterApiMode();
props.afterBulkImportTo();
assertEquals(Result.ERROR, props.validateBulkImportTo().getStatus());
MarketoSource source = new MarketoSource();
source.initialize(null, props);
assertEquals(Result.ERROR, source.validate(null).getStatus());
props.connection.apiMode.setValue(APIMode.REST);
props.connection.endpoint.setValue(ENDPOINT_REST);
props.connection.clientAccessId.setValue(USERID_REST);
props.connection.secretKey.setValue(SECRETKEY_REST);
props.bulkFilePath.setValue("");
source.initialize(null, props);
assertEquals(Result.ERROR, source.validate(null).getStatus());
props.bulkFilePath.setValue("inexistant.csv");
source.initialize(null, props);
assertEquals(Result.ERROR, source.validate(null).getStatus());
props.bulkFilePath.setValue(leadCSV);
source.initialize(null, props);
assertEquals(Result.ERROR, source.validate(null).getStatus());
props.logDownloadPath.setValue(downloadPath);
source.initialize(null, props);
assertEquals(Result.OK, source.validate(null).getStatus());
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoSOAPClientTestIT method testGetLead.
@Test
public void testGetLead() throws Exception {
inputProperties.inputOperation.setValue(getLead);
inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
inputProperties.afterInputOperation();
//
String email = EMAIL_UNDX00;
inputProperties.leadKeyValue.setValue(email);
MarketoSource source = new MarketoSource();
source.initialize(null, inputProperties);
MarketoClientService client = source.getClientService(null);
//
MarketoRecordResult result = client.getLead(inputProperties, null);
LOG.debug("{}", result);
List<IndexedRecord> records = result.getRecords();
assertNotEquals(emptyList(), records);
IndexedRecord record = records.get(0);
assertNotNull(record);
assertNotNull(record.get(0));
assertEquals(email, record.get(1));
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoSOAPClientTestIT method testGetMultipleLeadsLeadKeyFail.
@Test
public void testGetMultipleLeadsLeadKeyFail() throws Exception {
inputProperties.inputOperation.setValue(getMultipleLeads);
inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
inputProperties.afterInputOperation();
inputProperties.batchSize.setValue(100);
inputProperties.leadKeyValues.setValue("i-dont-exist@mail.com,bad-email@dot.net");
MarketoSource source = new MarketoSource();
source.initialize(null, inputProperties);
MarketoClientService client = source.getClientService(null);
MarketoRecordResult result = client.getMultipleLeads(inputProperties, null);
LOG.debug("{}", result);
// but no leads
assertTrue(result.isSuccess());
assertEquals(0, result.getRecordCount());
assertEquals(0, result.getRemainCount());
}
Aggregations