Search in sources :

Example 51 with MarketoSource

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

the class MarketoSOAPClientTestIT method testBadConnectionString.

@Test(expected = IOException.class)
public void testBadConnectionString() throws Exception {
    inputProperties.connection.endpoint.setValue("htps://marketo.com/rest/v1");
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    fail("Shouldn't be here");
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) Test(org.junit.Test)

Example 52 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLeadMany.

@Test
public void testGetLeadMany() throws Exception {
    inputProperties.inputOperation.setValue(getMultipleLeads);
    inputProperties.leadKeyTypeSOAP.setValue(LeadKeyTypeSOAP.IDNUM);
    inputProperties.leadKeyValues.setValue(createdLeads.toString().replaceAll("\\]|\\[|\\s", ""));
    inputProperties.afterInputOperation();
    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();
    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 53 with MarketoSource

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

the class MarketoSOAPClientTestIT method testSyncLead.

@Test
public void testSyncLead() 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("FirstName", Schema.create(Schema.Type.STRING), null, (Object) null);
    fields.add(field);
    field = new Schema.Field("LastName", Schema.create(Schema.Type.STRING), null, (Object) null);
    fields.add(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, "undx@undx.net");
    record.put(2, "ForeignPersonSysId");
    // CUSTOM, SFDC, NETSUITE;
    record.put(3, "SFDC");
    record.put(4, "My firstName");
    record.put(5, "My lastName");
    record.put(6, "Conservative customer");
    outProperties.schemaInput.schema.setValue(s);
    outProperties.beforeMappingInput();
    // 
    MarketoSyncResult result = client.syncLead(outProperties, record);
    assertEquals("UPDATED", result.getRecords().get(0).getStatus());
}
Also used : Field(org.apache.avro.Schema.Field) IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) IndexedRecord(org.apache.avro.generic.IndexedRecord) LeadRecord(com.marketo.mktows.LeadRecord) Field(org.apache.avro.Schema.Field) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 54 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetMultipleLeadsListNamePagination.

@Test
public void testGetMultipleLeadsListNamePagination() throws Exception {
    inputProperties.inputOperation.setValue(getMultipleLeads);
    inputProperties.leadSelectorSOAP.setValue(StaticListSelector);
    inputProperties.afterInputOperation();
    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);
    int counted = result.getRecordCount();
    assertTrue(result.getRecordCount() > 0);
    while (result.getRemainCount() > 0) {
        result = client.getMultipleLeads(inputProperties, 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 55 with MarketoSource

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

the class MarketoSOAPClientTestIT method testBUG_TDI38439_MarketoWizardConnection.

@Test
public void testBUG_TDI38439_MarketoWizardConnection() throws Exception {
    inputProperties.connection.endpoint.setValue(ENDPOINT_SOAP);
    inputProperties.connection.clientAccessId.setValue(USERID_SOAP);
    inputProperties.connection.secretKey.setValue(SECRETKEY_SOAP);
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    assertNotNull(client);
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) 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