Search in sources :

Example 11 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetMultipleLeadsListNameFail.

@Test
public void testGetMultipleLeadsListNameFail() throws Exception {
    inputProperties.inputOperation.setValue(getMultipleLeads);
    inputProperties.leadSelectorSOAP.setValue(StaticListSelector);
    inputProperties.updateSchemaRelated();
    inputProperties.batchSize.setValue(200);
    // 
    inputProperties.listParam.setValue(STATIC_LIST_NAME);
    inputProperties.listParamListName.setValue("undx_test_list******");
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getMultipleLeads(inputProperties, null);
    LOG.debug("{}", result);
    assertTrue(result.isSuccess());
    assertNotNull(result.getErrors());
    assertEquals(0, result.getRecordCount());
    assertEquals(0, result.getRemainCount());
    assertEquals(emptyList(), client.getMultipleLeads(inputProperties, null).getRecords());
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Example 12 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadsChangesExcludeFilter.

@Test
public void testGetLeadsChangesExcludeFilter() throws Exception {
    inputProperties.inputOperation.setValue(getLeadChanges);
    inputProperties.updateSchemaRelated();
    inputProperties.batchSize.setValue(1000);
    // 
    inputProperties.oldestCreateDate.setValue(DATE_OLDEST_CREATE);
    inputProperties.latestCreateDate.setValue(DATE_LATEST_CREATE);
    inputProperties.setExcludeTypes.setValue(true);
    inputProperties.excludeTypes.type.getValue().add(NewLead.toString());
    inputProperties.excludeTypes.type.getValue().add(ChangeDataValue.toString());
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLeadChanges(inputProperties, null);
    List<IndexedRecord> changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (IndexedRecord r : changes) {
        assertTrue(!"New Lead".equals(r.get(2)) && !"Change Data Value".equals(r.get(2)));
    }
}
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 13 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetMultipleLeadsListName.

@Test
public void testGetMultipleLeadsListName() throws Exception {
    inputProperties.inputOperation.setValue(getMultipleLeads);
    inputProperties.leadSelectorSOAP.setValue(StaticListSelector);
    inputProperties.updateSchemaRelated();
    inputProperties.batchSize.setValue(4);
    inputProperties.listParam.setValue(STATIC_LIST_NAME);
    inputProperties.listParamListName.setValue(UNDX_TEST_LIST_SMALL);
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getMultipleLeads(inputProperties, null);
    LOG.debug("{}", result);
    assertTrue(result.isSuccess());
    assertTrue(result.getRecordCount() > 3);
    assertTrue(result.getRemainCount() > 0);
    assertNotNull(result.getStreamPosition());
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Example 14 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadsChangesPagination.

@Test
public void testGetLeadsChangesPagination() throws Exception {
    inputProperties.inputOperation.setValue(getLeadChanges);
    inputProperties.updateSchemaRelated();
    inputProperties.batchSize.setValue(100);
    // 
    inputProperties.oldestCreateDate.setValue(DATE_OLDEST_CREATE);
    inputProperties.latestCreateDate.setValue(DATE_LATEST_CREATE);
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = null;
    List<IndexedRecord> changes = null;
    int totalRecords = 0;
    int counted = 0;
    result = client.getLeadChanges(inputProperties, null);
    totalRecords = result.getRecordCount() + result.getRemainCount();
    counted = result.getRecordCount();
    while (result.getRemainCount() > 0) {
        result = client.getLeadChanges(inputProperties, result.getStreamPosition());
        counted += result.getRecordCount();
        changes = result.getRecords();
        assertTrue(changes.size() > 0);
    }
    assertTrue(inputProperties.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 15 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadActivityPagination.

@Test
public void testGetLeadActivityPagination() throws Exception {
    inputProperties.inputOperation.setValue(getLeadActivity);
    inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
    inputProperties.leadSelectorSOAP.setValue(LeadKeySelector);
    inputProperties.updateSchemaRelated();
    inputProperties.batchSize.setValue(3);
    // 
    inputProperties.leadKeyValue.setValue(EMAIL_LEAD_MANY_INFOS);
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLeadActivity(inputProperties, null);
    int totalRecords = result.getRecordCount() + result.getRemainCount();
    int counted = result.getRecordCount();
    while (result.getRemainCount() > 0) {
        result = client.getLeadActivity(inputProperties, result.getStreamPosition());
        counted += result.getRecordCount();
    }
    assertEquals(totalRecords, counted);
}
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