Search in sources :

Example 71 with MarketoSource

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);
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Example 72 with MarketoSource

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());
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) MarketoError(org.talend.components.marketo.runtime.client.type.MarketoError) Test(org.junit.Test)

Example 73 with MarketoSource

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));
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Aggregations

MarketoSource (org.talend.components.marketo.runtime.MarketoSource)73 Test (org.junit.Test)72 MarketoRecordResult (org.talend.components.marketo.runtime.client.type.MarketoRecordResult)49 IndexedRecord (org.apache.avro.generic.IndexedRecord)37 MarketoSyncResult (org.talend.components.marketo.runtime.client.type.MarketoSyncResult)17 Schema (org.apache.avro.Schema)14 SyncStatus (org.talend.components.marketo.runtime.client.rest.type.SyncStatus)13 ArrayList (java.util.ArrayList)9 ListOperationParameters (org.talend.components.marketo.runtime.client.type.ListOperationParameters)7 Field (org.apache.avro.Schema.Field)5 Record (org.apache.avro.generic.GenericData.Record)4 MarketoError (org.talend.components.marketo.runtime.client.type.MarketoError)3 LeadRecord (com.marketo.mktows.LeadRecord)2 Path (java.nio.file.Path)2 GenericData (org.apache.avro.generic.GenericData)1