Search in sources :

Example 16 with MarketoSyncResult

use of org.talend.components.marketo.runtime.client.type.MarketoSyncResult 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 17 with MarketoSyncResult

use of org.talend.components.marketo.runtime.client.type.MarketoSyncResult 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 18 with MarketoSyncResult

use of org.talend.components.marketo.runtime.client.type.MarketoSyncResult 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 19 with MarketoSyncResult

use of org.talend.components.marketo.runtime.client.type.MarketoSyncResult 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)

Example 20 with MarketoSyncResult

use of org.talend.components.marketo.runtime.client.type.MarketoSyncResult in project components by Talend.

the class MarketoRESTClientTestIT method testAddToList.

/*
     * 
     * 
     * ListOperations
     *
     */
@Test
public void testAddToList() throws Exception {
    MarketoSource source = new MarketoSource();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(APIMode.REST.name());
    parms.setListId(UNDX_TEST_LIST_SMALL_ID);
    parms.setLeadIds(new Integer[] { createdLeads.get(10) });
    // 
    // first make sure to remove lead
    MarketoSyncResult result = client.removeFromList(parms);
    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);
    }
    // then add it
    result = client.addToList(parms);
    LOG.debug("result = {}.", result);
    changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertEquals("added", 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)

Aggregations

MarketoSyncResult (org.talend.components.marketo.runtime.client.type.MarketoSyncResult)29 SyncStatus (org.talend.components.marketo.runtime.client.rest.type.SyncStatus)20 Test (org.junit.Test)18 MarketoSource (org.talend.components.marketo.runtime.MarketoSource)17 ArrayList (java.util.ArrayList)13 IndexedRecord (org.apache.avro.generic.IndexedRecord)10 Schema (org.apache.avro.Schema)9 ListOperationParameters (org.talend.components.marketo.runtime.client.type.ListOperationParameters)8 MarketoError (org.talend.components.marketo.runtime.client.type.MarketoError)5 Field (org.apache.avro.Schema.Field)4 Record (org.apache.avro.generic.GenericData.Record)4 MarketoException (org.talend.components.marketo.runtime.client.type.MarketoException)4 MalformedURLException (java.net.MalformedURLException)3 InvalidKeyException (java.security.InvalidKeyException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 ParseException (java.text.ParseException)3 JAXBContext (javax.xml.bind.JAXBContext)3 JAXBException (javax.xml.bind.JAXBException)3 Marshaller (javax.xml.bind.Marshaller)3 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)3