Search in sources :

Example 56 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetMultipleLeadsListIdFail.

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

Example 57 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadActivityIncludeFilter.

@Test
public void testGetLeadActivityIncludeFilter() throws Exception {
    inputProperties.inputOperation.setValue(getLeadActivity);
    inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
    inputProperties.leadSelectorSOAP.setValue(LeadKeySelector);
    inputProperties.updateSchemaRelated();
    inputProperties.batchSize.setValue(11);
    // 
    inputProperties.leadKeyValue.setValue(EMAIL_LEAD_MANY_INFOS);
    inputProperties.setIncludeTypes.setValue(true);
    inputProperties.includeTypes.type.getValue().add(NewLead.toString());
    inputProperties.includeTypes.type.getValue().add(ChangeDataValue.toString());
    // inputProperties.includeTypes.type.getValue().add(TMarketoInputProperties.IncludeExcludeFieldsSOAP.VisitWebpage.toString());
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLeadActivity(inputProperties, null);
    List<IndexedRecord> activities = result.getRecords();
    assertTrue(activities.size() > 0);
    for (IndexedRecord r : activities) {
        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 58 with MarketoSource

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

the class MarketoRESTClientTestIT method testGetCustomObjectDynamic.

@Test
public void testGetCustomObjectDynamic() throws Exception {
    String coName = "smartphone_c";
    String brand = "Samsung";
    String models = "Galaxy S7,XCover";
    iprops.inputOperation.setValue(CustomObject);
    iprops.customObjectAction.setValue(CustomObjectAction.get);
    iprops.batchSize.setValue(1);
    iprops.afterCustomObjectAction();
    iprops.customObjectName.setValue(coName);
    iprops.customObjectFilterType.setValue("model");
    iprops.customObjectFilterValues.setValue(models);
    iprops.schemaInput.schema.setValue(SchemaBuilder.builder().record("test").prop(SchemaConstants.INCLUDE_ALL_FIELDS, "true").fields().endRecord());
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    Schema runtimeSchema = source.getDynamicSchema(coName, iprops.schemaInput.schema.getValue());
    LOG.debug("runtimeSchema = {}.", runtimeSchema);
    iprops.schemaInput.schema.setValue(runtimeSchema);
    MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
    MarketoRecordResult result = client.getCustomObjects(iprops, null);
    assertTrue(result.isSuccess());
    for (IndexedRecord r : result.getRecords()) {
        LOG.debug("r = {}.", r);
        assertNotNull(r);
        assertEquals(brand, r.get(runtimeSchema.getField("brand").pos()));
        assertTrue(models.contains(r.get(runtimeSchema.getField("model").pos()).toString()));
        assertNotNull(r.get(runtimeSchema.getField("customerId").pos()));
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Example 59 with MarketoSource

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

the class MarketoRESTClientTestIT method testGetLeadActivityExcludeFilter.

@Test
public void testGetLeadActivityExcludeFilter() throws Exception {
    iprops.inputOperation.setValue(getLeadActivity);
    iprops.afterInputOperation();
    iprops.batchSize.setValue(300);
    iprops.excludeTypes.type.getValue().add(IncludeExcludeFieldsSOAP.VisitWebpage.toString());
    iprops.excludeTypes.type.getValue().add(ChangeDataValue.toString());
    iprops.sinceDateTime.setValue(DATE_OLDEST_CREATE);
    iprops.beforeMappingInput();
    // 
    MarketoSource source = new MarketoSource();
    source.initialize(null, iprops);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLeadActivity(iprops, null);
    LOG.debug("{}", result);
    List<IndexedRecord> activities = result.getRecords();
    assertTrue(activities.size() > 0);
    for (IndexedRecord r : activities) {
        assertTrue(!"Visit Webpage".equals(r.get(4)) && !"Change Data Value".equals(r.get(4)));
    }
}
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 60 with MarketoSource

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

the class MarketoRESTClientTestIT method testSyncLead.

/*
     *
     *
     * syncLeads
     *
     */
@Test
public void testSyncLead() throws Exception {
    outProperties.outputOperation.setValue(OutputOperation.syncLead);
    outProperties.operationType.setValue(OperationType.createOrUpdate);
    outProperties.lookupField.setValue(RESTLookupFields.email);
    outProperties.deDupeEnabled.setValue(false);
    outProperties.updateSchemaRelated();
    outProperties.updateOutputSchemas();
    MarketoSource source = new MarketoSource();
    source.initialize(null, outProperties);
    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);
    IndexedRecord record = new GenericData.Record(s);
    record.put(0, null);
    record.put(1, "undx71@undx.net");
    record.put(2, "ForeignPersonSysId");
    // CUSTOM, SFDC, NETSUITE;
    record.put(3, "SFDC");
    record.put(4, "My firstName");
    List<IndexedRecord> leads = Arrays.asList(record);
    outProperties.schemaInput.schema.setValue(s);
    outProperties.beforeMappingInput();
    // /
    MarketoSyncResult result = client.syncLead(outProperties, record);
    LOG.debug("result = {}.", result);
    List<SyncStatus> changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        LOG.debug("r = {}.", r);
    }
}
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) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) 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