Search in sources :

Example 16 with MarketoSource

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

the class MarketoSOAPClientTestIT method testAddToListFail.

@Test
public void testAddToListFail() throws Exception {
    MarketoSource source = new MarketoSource();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(SOAP.name());
    parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
    parms.setLeadKeyValue(new String[] { "12345" });
    // first make sure to remove lead
    MarketoSyncResult result;
    List<SyncStatus> changes;
    result = client.addToList(parms);
    LOG.debug("result = {}.", result);
    changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertFalse(Boolean.parseBoolean(r.getStatus()));
        assertEquals("[20103] Lead Not Found.", r.getAvailableReason());
        LOG.debug("r = {}.", r);
    }
}
Also used : ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 17 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetMultipleLeadsLeadKeyWithInputComponent.

@Test
public void testGetMultipleLeadsLeadKeyWithInputComponent() throws Exception {
    inputProperties.inputOperation.setValue(getMultipleLeads);
    inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
    inputProperties.afterInputOperation();
    inputProperties.batchSize.setValue(100);
    inputProperties.leadKeyValues.setValue("undx00@undx.net,undx10@undx.net,undx20@undx.net,undx30@undx.net");
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getMultipleLeads(inputProperties, null);
    LOG.debug("{}", result);
    List<IndexedRecord> records = result.getRecords();
    assertEquals(4, records.size());
}
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 18 with MarketoSource

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

the class MarketoSOAPClientTestIT method testRemoveFromList.

@Test
public void testRemoveFromList() throws Exception {
    MarketoSource source = new MarketoSource();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(SOAP.name());
    parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
    parms.setLeadKeyValue(new String[] { createdLeads.get(20).toString() });
    // first subscribe lead
    MarketoSyncResult result = client.addToList(parms);
    List<SyncStatus> changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertTrue(Boolean.parseBoolean(r.getStatus()));
        LOG.debug("r = {}.", r);
    }
    // then remove it
    result = client.removeFromList(parms);
    LOG.debug("result = {}.", result);
    changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertTrue(Boolean.parseBoolean(r.getStatus()));
        LOG.debug("r = {}.", r);
    }
}
Also used : ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 19 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadsChangesIncludeFilter.

@Test
public void testGetLeadsChangesIncludeFilter() 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.setIncludeTypes.setValue(true);
    inputProperties.includeTypes.type.getValue().add(NewLead.toString());
    inputProperties.includeTypes.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 20 with MarketoSource

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

the class MarketoRESTClientTestIT method testGetLeadFailWrongHost.

@Test(expected = IOException.class)
public void testGetLeadFailWrongHost() throws Exception {
    iprops.inputOperation.setValue(getLead);
    iprops.leadKeyTypeREST.setValue(email);
    iprops.connection.endpoint.setValue(ENDPOINT_URL_INEXISTANT);
    iprops.afterInputOperation();
    // 
    iprops.leadKeyValue.setValue(EMAIL_INEXISTANT);
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    MarketoClientService client = null;
    client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLead(iprops, null);
    LOG.debug("{}", result);
    List<IndexedRecord> records = result.getRecords();
    assertEquals(emptyList(), records);
}
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)

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