Search in sources :

Example 46 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetMultipleLeadsListId.

@Test
public void testGetMultipleLeadsListId() throws Exception {
    inputProperties.inputOperation.setValue(getMultipleLeads);
    inputProperties.leadSelectorSOAP.setValue(StaticListSelector);
    inputProperties.updateSchemaRelated();
    inputProperties.batchSize.setValue(10);
    // 
    inputProperties.listParam.setValue(STATIC_LIST_ID);
    inputProperties.listParamListId.setValue(UNDX_TEST_LIST_SMALL_ID);
    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.getErrors().isEmpty());
    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 47 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadActivity.

@Test
public void testGetLeadActivity() throws Exception {
    inputProperties.inputOperation.setValue(getLeadActivity);
    inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
    inputProperties.leadSelectorSOAP.setValue(LeadKeySelector);
    inputProperties.afterInputOperation();
    inputProperties.beforeMappingInput();
    inputProperties.batchSize.setValue(11);
    // 
    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);
    LOG.debug("{}", result);
    assertTrue(result.isSuccess());
    List<IndexedRecord> records = result.getRecords();
    assertTrue(records.size() > 0);
    for (IndexedRecord r : records) {
        assertNotNull(r.get(0));
        assertTrue(r.get(0) instanceof Long);
    }
}
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 48 with MarketoSource

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

the class MarketoSOAPClientTestIT method testIsMemberOfList.

@Test
public void testIsMemberOfList() 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.setStrict(true);
    parms.setLeadKeyValue(new String[] { createdLeads.get(0).toString(), createdLeads.get(1).toString(), createdLeads.get(2).toString(), "12345" });
    // 
    MarketoSyncResult result = client.isMemberOfList(parms);
    LOG.debug("result = {}.", result);
    List<SyncStatus> changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertNotNull(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 49 with MarketoSource

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

the class MarketoSOAPClientTestIT method testSyncMultipleLeads.

@Test
public void testSyncMultipleLeads() throws Exception {
    MarketoSource source = new MarketoSource();
    outProperties.outputOperation.setValue(OutputOperation.syncLead);
    outProperties.updateSchemaRelated();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // test attributes
    List<Field> fields = new ArrayList<>();
    Field field = new Schema.Field("AccountType", Schema.create(Schema.Type.STRING), null, (Object) null);
    fields.add(field);
    Schema s = MarketoUtils.newSchema(outProperties.schemaInput.schema.getValue(), "leadAttribute", fields);
    outProperties.schemaInput.schema.setValue(s);
    outProperties.beforeMappingInput();
    List<IndexedRecord> records = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        IndexedRecord record = new GenericData.Record(s);
        record.put(0, null);
        record.put(1, "undx" + i + "@undx.net");
        record.put(2, "");
        // CUSTOM, SFDC, NETSUITE;
        record.put(3, "CUSTOM");
        record.put(4, "customer" + i);
        records.add(record);
    }
    // 
    MarketoSyncResult result = client.syncMultipleLeads(outProperties, records);
    for (SyncStatus status : result.getRecords()) {
        assertEquals("CREATED", status.getStatus());
    }
    // 
    outProperties.deDupeEnabled.setValue(true);
    result = client.syncMultipleLeads(outProperties, records);
    for (SyncStatus status : result.getRecords()) {
        assertEquals("UPDATED", status.getStatus());
    }
}
Also used : Field(org.apache.avro.Schema.Field) IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) IndexedRecord(org.apache.avro.generic.IndexedRecord) LeadRecord(com.marketo.mktows.LeadRecord) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 50 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadFail.

@Test
public void testGetLeadFail() throws Exception {
    inputProperties.inputOperation.setValue(getLead);
    inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
    inputProperties.afterInputOperation();
    // 
    inputProperties.leadKeyValue.setValue(EMAIL_INEXISTANT);
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLead(inputProperties, null);
    List<IndexedRecord> records = result.getRecords();
    assertEquals(emptyList(), records);
    LOG.debug("record = " + 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