use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testGetLeadDynamic.
/*
*
* Dynamic fields
*
*/
@Test
public void testGetLeadDynamic() throws Exception {
iprops.inputOperation.setValue(getLead);
iprops.leadKeyTypeREST.setValue(LeadKeyTypeREST.id);
iprops.batchSize.setValue(1);
iprops.afterInputOperation();
iprops.leadKeyValue.setValue(createdLeads.get(0).toString());
iprops.schemaInput.schema.setValue(SchemaBuilder.builder().record("test").prop(SchemaConstants.INCLUDE_ALL_FIELDS, "true").fields().endRecord());
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
Schema design = this.iprops.schemaInput.schema.getValue();
// preserve mappings to re-apply them after
Map<String, String> mappings = iprops.mappingInput.getNameMappingsForMarketo();
Schema runtimeSchema = source.getDynamicSchema("", design);
List<String> columnNames = new ArrayList<>();
List<String> mktoNames = new ArrayList<>();
for (Field f : runtimeSchema.getFields()) {
columnNames.add(f.name());
if (mappings.get(f.name()) != null) {
mktoNames.add(mappings.get(f.name()));
} else {
mktoNames.add("");
}
}
iprops.mappingInput.columnName.setValue(columnNames);
iprops.mappingInput.marketoColumnName.setValue(mktoNames);
iprops.schemaInput.schema.setValue(runtimeSchema);
MarketoRecordResult result = client.getLead(iprops, null);
LOG.debug("result = {}.", result);
IndexedRecord r = result.getRecords().get(0);
assertNotNull(r);
LOG.debug("r = {}.", r);
assertEquals("Retail-Dev", r.get(runtimeSchema.getField("company").pos()));
assertEquals(COMMON_LINKEDIN_ID.toString(), r.get(runtimeSchema.getField("linkedInId").pos()));
assertEquals(COMMON_SFDC_ACCOUNT_ID, r.get(runtimeSchema.getField("sfdcAccountId").pos()));
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testGetLead.
/*
*
* ************************ getLead ************************
*
*/
@Test
public void testGetLead() throws Exception {
iprops.inputOperation.setValue(getLead);
iprops.leadKeyTypeREST.setValue(email);
iprops.afterInputOperation();
//
String email = EMAIL_UNDX00;
iprops.leadKeyValue.setValue(email);
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoClientService client = source.getClientService(null);
assertTrue(((MarketoRESTClient) client).isAvailable());
//
MarketoRecordResult result = client.getLead(iprops, 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));
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testGetMultipleLeadsLeadKey.
/*
*
* ************************ getMultipleLeads ************************
*
*/
@Test
public void testGetMultipleLeadsLeadKey() throws Exception {
iprops.inputOperation.setValue(getMultipleLeads);
iprops.afterInputOperation();
iprops.batchSize.setValue(100);
iprops.leadKeyTypeREST.setValue(email);
iprops.leadKeyValues.setValue("undx00@undx.net,undx10@undx.net,undx20@undx.net,undx30@undx.net");
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoClientService client = source.getClientService(null);
//
MarketoRecordResult result = client.getMultipleLeads(iprops, null);
LOG.debug("{}", result);
List<IndexedRecord> records = result.getRecords();
assertTrue(records.size() >= 4);
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testBadURIConnectionString.
@Test(expected = IOException.class)
public void testBadURIConnectionString() throws Exception {
iprops.connection.endpoint.setValue("htps:marketo.comrestv1");
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoClientService client = source.getClientService(null);
fail("Shouldn't be here");
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT 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(APIMode.REST.name());
parms.setListId(UNDX_TEST_LIST_SMALL_ID);
parms.setLeadIds(new Integer[] { createdLeads.get(0), createdLeads.get(1), createdLeads.get(2) });
//
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());
assertEquals("memberof", r.getStatus());
LOG.debug("r = {}.", r);
}
}
Aggregations