use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testListCustomObjects.
@Test
public void testListCustomObjects() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, irProps);
MarketoClientServiceExtended client = (MarketoClientServiceExtended) source.getClientService(null);
irProps.customObjectNames.setValue("smartphone_c,roadShow_c,car_c");
MarketoRecordResult result = client.listCustomObjects(irProps);
assertNotNull(result.getRecords());
assertEquals(3, result.getRecords().size());
for (IndexedRecord r : result.getRecords()) {
checkCustomObject(r, false);
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testGetCustomObjectsFail.
@Test
public void testGetCustomObjectsFail() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, irProps);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
irProps.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
// cannot search by brand, must be a dedupe
irProps.customObjectFilterType.setValue(FIELD_CO_SMARTPHONE_BRAND);
// field.
irProps.customObjectFilterValues.setValue(TEST_SMARTPHONE_BRAND_SAMSUNG);
irProps.batchSize.setValue(500);
irProps.schemaInput.schema.setValue(MarketoConstants.getCustomObjectRecordSchema());
MarketoRecordResult result = client.getCustomObjects(irProps, null);
assertFalse(result.isSuccess());
assertEquals(0, result.getRecordCount());
assertNotNull(result.getErrors());
Object err = result.getErrors().get(0);
assertTrue(err instanceof MarketoError);
assertEquals("REST", ((MarketoError) err).getApiMode());
assertEquals("1003", ((MarketoError) err).getCode());
assertEquals("Invalid filterType 'brand'", ((MarketoError) err).getMessage());
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testGetCustomObjectsPagination.
@Test
public void testGetCustomObjectsPagination() throws Exception {
MarketoSyncResult rs = createCustomObjectRecords("");
MarketoSource source = new MarketoSource();
source.initialize(null, irProps);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
irProps.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
irProps.batchSize.setValue(1);
irProps.schemaInput.schema.setValue(MarketoConstants.getCustomObjectRecordSchema());
irProps.customObjectFilterType.setValue(FIELD_CO_SMARTPHONE_MODEL);
irProps.customObjectFilterValues.setValue(MarketoRESTClient.csvString(TEST_SMARTPHONE_MODELS));
MarketoRecordResult result = client.getCustomObjects(irProps, null);
assertNotNull(result.getRecords());
assertTrue(result.getRemainCount() > 0);
assertEquals(1, result.getRecords().size());
LOG.debug("result = {}.", result.getRecords().get(0));
result = client.getCustomObjects(irProps, result.getStreamPosition());
assertNotNull(result.getRecords());
assertEquals(1, result.getRecords().size());
checkCustomObjectRecord(result.getRecords().get(0));
}
Aggregations