Search in sources :

Example 31 with MarketoSource

use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.

the class MarketoRESTClientTestIT method testGetMultipleLeadsListId.

@Test
public void testGetMultipleLeadsListId() throws Exception {
    iprops.inputOperation.setValue(getMultipleLeads);
    iprops.afterInputOperation();
    iprops.batchSize.setValue(10);
    // 
    iprops.leadSelectorREST.setValue(StaticListSelector);
    iprops.listParam.setValue(STATIC_LIST_ID);
    iprops.listParamListId.setValue(UNDX_TEST_LIST_SMALL_ID);
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getMultipleLeads(iprops, null);
    LOG.debug("{}", result);
    assertTrue(result.isSuccess());
    assertNotNull(result.getErrors());
    assertNotEquals(0, result.getRecordCount());
    assertNotEquals(0, result.getRemainCount());
    assertTrue(result.getRecordCount() > 4);
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Example 32 with MarketoSource

use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.

the class MarketoRESTClientTestIT method testGetMultipleLeadsListNamePagination.

@Test
public void testGetMultipleLeadsListNamePagination() throws Exception {
    iprops.inputOperation.setValue(getMultipleLeads);
    iprops.afterInputOperation();
    iprops.batchSize.setValue(104);
    iprops.leadSelectorREST.setValue(StaticListSelector);
    iprops.listParam.setValue(STATIC_LIST_NAME);
    iprops.listParamListName.setValue(UNDX_TEST_LIST_SMALL);
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getMultipleLeads(iprops, null);
    int counted = result.getRecordCount();
    assertTrue(result.getRecordCount() > 0);
    while (result.getRemainCount() > 0) {
        result = client.getMultipleLeads(iprops, result.getStreamPosition());
        assertNotNull(result.getRecords().get(0).get(0));
        LOG.debug("{}", result);
        counted += result.getRecordCount();
    }
    LOG.debug(result.getRecords().get(0).getSchema().toString());
    assertEquals("int", result.getRecords().get(0).getSchema().getField("id").schema().getTypes().get(0).getName());
    assertTrue(counted > 4);
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Example 33 with MarketoSource

use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.

the class MarketoRESTClientTestIT method testGetLeadsChangesPagination.

@Test
public void testGetLeadsChangesPagination() throws Exception {
    iprops.afterInputOperation();
    iprops.batchSize.setValue(300);
    iprops.sinceDateTime.setValue(DATE_OLDEST_CREATE);
    iprops.fieldList.setValue("id,email,firstName,lastName,company");
    // 
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLeadChanges(iprops, null);
    LOG.debug("{}", result);
    List<IndexedRecord> changes = null;
    int counted = 0;
    result = client.getLeadChanges(iprops, null);
    counted = result.getRecordCount();
    while (result.getRemainCount() > 0) {
        result = client.getLeadChanges(iprops, result.getStreamPosition());
        counted += result.getRecordCount();
        changes = result.getRecords();
    }
    assertTrue(iprops.batchSize.getValue() < counted);
}
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 34 with MarketoSource

use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.

the class MarketoRESTClientTestIT method testGetLeadMany.

@Test
public void testGetLeadMany() throws Exception {
    iprops.inputOperation.setValue(getLead);
    iprops.leadKeyTypeREST.setValue(linkedInId);
    iprops.afterInputOperation();
    iprops.leadKeyValue.setValue(COMMON_LINKEDIN_ID.toString());
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLead(iprops, null);
    LOG.debug("{}", result);
    List<IndexedRecord> records = result.getRecords();
    int count = 0;
    assertNotEquals(emptyList(), records);
    for (IndexedRecord record : records) {
        count++;
        assertNotNull(record);
        // id
        assertNotNull(record.get(0));
        assertTrue(record.get(1).toString().startsWith(EMAIL_PREFIX));
    }
    assertEquals(50, count);
}
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 35 with MarketoSource

use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.

the class MarketoRESTClientTestIT method testGetMultipleLeadsLeadKeyFail.

@Test
public void testGetMultipleLeadsLeadKeyFail() throws Exception {
    iprops.inputOperation.setValue(getMultipleLeads);
    iprops.afterInputOperation();
    iprops.batchSize.setValue(100);
    iprops.leadKeyTypeREST.setValue(email);
    iprops.leadKeyValues.setValue("i-dont-exist@mail.com,bad-email@dot.net");
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    MarketoClientService client = source.getClientService(null);
    MarketoRecordResult result = client.getMultipleLeads(iprops, null);
    LOG.debug("{}", result);
    // but no leads
    assertTrue(result.isSuccess());
    assertEquals(0, result.getRecordCount());
    assertEquals(0, result.getRemainCount());
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) 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