use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testGetLeadActivityPagination.
@Test
public void testGetLeadActivityPagination() throws Exception {
iprops.inputOperation.setValue(getLeadActivity);
iprops.afterInputOperation();
iprops.batchSize.setValue(300);
iprops.sinceDateTime.setValue(DATE_LATEST_UPDATE);
iprops.beforeMappingInput();
//
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoClientService client = source.getClientService(null);
//
MarketoRecordResult result = client.getLeadActivity(iprops, null);
int counted = result.getRecordCount();
while (result.getRemainCount() > 0) {
result = client.getLeadActivity(iprops, result.getStreamPosition());
counted += result.getRecordCount();
}
assertTrue(counted >= iprops.batchSize.getValue());
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testDeleteLeads.
/*
*
* management func
*
*/
@Test
public void testDeleteLeads() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, outProperties);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
//
Integer[] ids = { 0, 1, 2, 2 };
MarketoSyncResult result = client.deleteLeads(ids);
LOG.debug("result = {}.", result);
List<SyncStatus> changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertEquals("skipped", r.getStatus());
LOG.debug("r = {}.", r);
}
// writer
outProperties.outputOperation.setValue(OutputOperation.deleteLeads);
outProperties.afterOutputOperation();
List<IndexedRecord> leads = new ArrayList<>();
Schema s = outProperties.schemaInput.schema.getValue();
IndexedRecord record;
for (int i = 0; i < 10; i++) {
record = new GenericData.Record(s);
record.put(0, createdLeads.get(i));
leads.add(record);
}
// Non existing lead
record = new GenericData.Record(s);
record.put(0, 123);
leads.add(record);
MarketoSyncResult rs = client.deleteLeads(leads);
for (SyncStatus sync : rs.getRecords()) {
assertNotNull(sync);
LOG.debug("sync = {}.", sync);
if (sync.getId().equals(123)) {
assertEquals("skipped", sync.getStatus());
assertEquals("[1004] Lead not found.", sync.getAvailableReason());
} else {
assertEquals("deleted", sync.getStatus());
}
}
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testDeleteCustomObjectsFailWithWrongFields.
@Test
public void testDeleteCustomObjectsFailWithWrongFields() throws Exception {
MarketoSyncResult rs = createCustomObjectRecords("");
assertTrue(rs.isSuccess());
//
oprops.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
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);
rs = client.deleteCustomObjects(oprops, records);
assertTrue(rs.isSuccess());
List<SyncStatus> changes = rs.getRecords();
assertEquals(TEST_SMARTPHONE_MODELS.length, changes.size());
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getSeq());
assertEquals(STATUS_SKIPPED, r.getStatus());
}
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testDeleteCustomObjectsByDedupeFields.
@Test
public void testDeleteCustomObjectsByDedupeFields() throws Exception {
MarketoSyncResult rs = createCustomObjectRecords("");
assertTrue(rs.isSuccess());
//
oprops.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
Schema s = //
SchemaBuilder.record("sn").fields().name(FIELD_CO_SMARTPHONE_MODEL).type().stringType().noDefault().endRecord();
List<IndexedRecord> records = new ArrayList<>();
IndexedRecord r1;
for (String m : TEST_SMARTPHONE_MODELS) {
r1 = new Record(s);
r1.put(0, m);
records.add(r1);
}
MarketoSource source = new MarketoSource();
oprops.customObjectDeleteBy.setValue(CustomObjectDeleteBy.dedupeFields);
source.initialize(null, oprops);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
rs = client.deleteCustomObjects(oprops, records);
assertTrue(rs.isSuccess());
List<SyncStatus> changes = rs.getRecords();
assertEquals(TEST_SMARTPHONE_MODELS.length, changes.size());
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getSeq());
assertEquals(STATUS_DELETED, r.getStatus());
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testDescribeCustomObject.
@Test
public void testDescribeCustomObject() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, irProps);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
irProps.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
MarketoRecordResult result = client.describeCustomObject(irProps);
assertNotNull(result.getRecords());
assertEquals(1, result.getRecords().size());
LOG.debug("result = {}.", result.getRecords().get(0));
checkCustomObject(result.getRecords().get(0), true);
}
Aggregations