Search in sources :

Example 41 with MarketoSource

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

the class MarketoClientCustomObjectsTestIT method testGetCustomObjectWithCompoundKey.

@Test
public void testGetCustomObjectWithCompoundKey() throws Exception {
    irProps.customObjectAction.setValue(CustomObjectAction.get);
    irProps.customObjectName.setValue(TEST_CO_NAME_CAR);
    irProps.validateFetchCustomObjectSchema();
    irProps.useCompoundKey.setValue(true);
    // "searchableFields": "[[\"customerId\",\"VIN\"],[\"marketoGUID\"],[\"customerId\"]]"
    irProps.compoundKey.keyName.setValue(Arrays.asList("customerId", "VIN"));
    // WBA4R7C55HK895912
    irProps.compoundKey.keyValue.setValue(Arrays.asList("4137181", "WBA4R7C30HK896061"));
    MarketoSource source = new MarketoSource();
    source.initialize(null, irProps);
    MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
    MarketoRecordResult result = client.getCustomObjects(irProps, null);
    LOG.debug("result = {}.", result);
    assertNotNull(result.getRecords());
    assertEquals(1, result.getRecords().size());
    IndexedRecord record = result.getRecords().get(0);
    Schema s = record.getSchema();
    assertEquals(4137181, record.get(s.getField("customerId").pos()));
    assertEquals("WBA4R7C30HK896061", record.get(s.getField("VIN").pos()));
    assertEquals("FIT", record.get(s.getField("brand").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 42 with MarketoSource

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

the class MarketoClientCustomObjectsTestIT method createCustomObjectRecords.

public MarketoSyncResult createCustomObjectRecords(String dedupeBy) throws Exception {
    oprops.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
    oprops.customObjectSyncAction.setValue(CustomObjectSyncAction.createOrUpdate);
    oprops.customObjectDedupeBy.setValue(dedupeBy);
    Schema s = // 
    SchemaBuilder.record("sn").fields().name(FIELD_CO_SMARTPHONE_BRAND).type().stringType().noDefault().name(FIELD_CO_SMARTPHONE_MODEL).type().stringType().noDefault().name(FIELD_CO_SMARTPHONE_CUSTOMER_ID).type().intType().noDefault().endRecord();
    List<IndexedRecord> records = new ArrayList<>();
    IndexedRecord r1;
    for (String m : TEST_SMARTPHONE_MODELS) {
        r1 = new Record(s);
        r1.put(0, TEST_SMARTPHONE_BRAND_SAMSUNG);
        r1.put(1, m);
        r1.put(2, 3113479);
        records.add(r1);
    }
    MarketoSource source = new MarketoSource();
    source.initialize(null, irProps);
    MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
    MarketoSyncResult rs = client.syncCustomObjects(oprops, records);
    return rs;
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) Record(org.apache.avro.generic.GenericData.Record) IndexedRecord(org.apache.avro.generic.IndexedRecord) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult)

Example 43 with MarketoSource

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

the class MarketoRESTClientBulkExecTestIT method testBulkExecValidate.

@Test
public void testBulkExecValidate() throws Exception {
    props.bulkImportTo.setValue(BulkImportTo.Leads);
    props.bulkFilePath.setValue(leadCSV);
    props.logDownloadPath.setValue("/Users/undx/mp/");
    props.pollWaitTime.setValue(1);
    props.connection.apiMode.setValue(APIMode.SOAP);
    props.connection.endpoint.setValue(ENDPOINT_SOAP);
    props.connection.clientAccessId.setValue(USERID_SOAP);
    props.connection.secretKey.setValue(SECRETKEY_SOAP);
    props.connection.afterApiMode();
    props.afterBulkImportTo();
    assertEquals(Result.ERROR, props.validateBulkImportTo().getStatus());
    MarketoSource source = new MarketoSource();
    source.initialize(null, props);
    assertEquals(Result.ERROR, source.validate(null).getStatus());
    props.connection.apiMode.setValue(APIMode.REST);
    props.connection.endpoint.setValue(ENDPOINT_REST);
    props.connection.clientAccessId.setValue(USERID_REST);
    props.connection.secretKey.setValue(SECRETKEY_REST);
    props.bulkFilePath.setValue("");
    source.initialize(null, props);
    assertEquals(Result.ERROR, source.validate(null).getStatus());
    props.bulkFilePath.setValue("inexistant.csv");
    source.initialize(null, props);
    assertEquals(Result.ERROR, source.validate(null).getStatus());
    props.bulkFilePath.setValue(leadCSV);
    source.initialize(null, props);
    assertEquals(Result.ERROR, source.validate(null).getStatus());
    props.logDownloadPath.setValue(downloadPath);
    source.initialize(null, props);
    assertEquals(Result.OK, source.validate(null).getStatus());
}
Also used : MarketoSource(org.talend.components.marketo.runtime.MarketoSource) Test(org.junit.Test)

Example 44 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetLead.

@Test
public void testGetLead() throws Exception {
    inputProperties.inputOperation.setValue(getLead);
    inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
    inputProperties.afterInputOperation();
    // 
    String email = EMAIL_UNDX00;
    inputProperties.leadKeyValue.setValue(email);
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    MarketoRecordResult result = client.getLead(inputProperties, null);
    LOG.debug("{}", result);
    List<IndexedRecord> records = result.getRecords();
    assertNotEquals(emptyList(), records);
    IndexedRecord record = records.get(0);
    assertNotNull(record);
    assertNotNull(record.get(0));
    assertEquals(email, record.get(1));
}
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 45 with MarketoSource

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

the class MarketoSOAPClientTestIT method testGetMultipleLeadsLeadKeyFail.

@Test
public void testGetMultipleLeadsLeadKeyFail() throws Exception {
    inputProperties.inputOperation.setValue(getMultipleLeads);
    inputProperties.leadKeyTypeSOAP.setValue(EMAIL);
    inputProperties.afterInputOperation();
    inputProperties.batchSize.setValue(100);
    inputProperties.leadKeyValues.setValue("i-dont-exist@mail.com,bad-email@dot.net");
    MarketoSource source = new MarketoSource();
    source.initialize(null, inputProperties);
    MarketoClientService client = source.getClientService(null);
    MarketoRecordResult result = client.getMultipleLeads(inputProperties, null);
    LOG.debug("{}", result);
    // but no leads
    assertTrue(result.isSuccess());
    assertEquals(0, result.getRecordCount());
    assertEquals(0, result.getRemainCount());
}
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