use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testGetLeadSchema.
@Test
public void testGetLeadSchema() throws Exception {
iprops.inputOperation.setValue(getLead);
iprops.leadKeyTypeREST.setValue(email);
iprops.afterInputOperation();
String email = EMAIL_LEAD_MANY_INFOS;
iprops.leadKeyValue.setValue(email);
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoClientService client = source.getClientService(null);
//
MarketoRecordResult result = client.getLead(iprops, null);
LOG.debug("{}", result);
List<IndexedRecord> records = result.getRecords();
assertNotEquals(emptyList(), records);
IndexedRecord record = records.get(0);
assertNotNull(record);
Schema s = record.getSchema();
assertEquals(s, MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
LOG.debug("record = {}.", record);
assertEquals("int", s.getField("id").schema().getTypes().get(0).getName());
assertEquals("string", s.getField("email").schema().getTypes().get(0).getName());
assertEquals(email, record.get(1));
assertEquals("string", s.getField("email").schema().getTypes().get(0).getName());
assertEquals("string", s.getField("firstName").schema().getTypes().get(0).getName());
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testGetLeadActivity.
/*
*
* ************************ getLeadActivity ************************
*
*/
@Test
public void testGetLeadActivity() throws Exception {
iprops.inputOperation.setValue(getLeadActivity);
iprops.afterInputOperation();
iprops.batchSize.setValue(50);
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);
assertTrue(result.isSuccess());
assertTrue(result.getRecordCount() > 0);
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testGetMultipleLeadsListName.
@Test
public void testGetMultipleLeadsListName() throws Exception {
iprops.inputOperation.setValue(getMultipleLeads);
iprops.afterInputOperation();
// we have at least 5 members with createDatasets.
iprops.batchSize.setValue(4);
iprops.leadSelectorREST.setValue(StaticListSelector);
iprops.listParam.setValue(STATIC_LIST_NAME);
iprops.listParamListName.setValue(UNDX_TEST_LIST_SMALL);
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoClientService client = source.getClientService(null);
//
MarketoRecordResult result = client.getMultipleLeads(iprops, null);
LOG.debug("{}", result);
assertTrue(result.isSuccess());
assertTrue(result.getRecordCount() > 3);
assertTrue(result.getRemainCount() > 0);
assertNotNull(result.getStreamPosition());
}
use of org.talend.components.marketo.runtime.MarketoSource 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);
}
}
use of org.talend.components.marketo.runtime.MarketoSource in project components by Talend.
the class MarketoRESTClientTestIT method testIsAccessTokenExpired.
@Test
public void testIsAccessTokenExpired() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, iprops);
MarketoClientService client = source.getClientService(null);
assertFalse(((MarketoRESTClient) client).isAccessTokenExpired(null));
MarketoError err = new MarketoError("REST", "200", "dfddf");
assertFalse(((MarketoRESTClient) client).isAccessTokenExpired(Arrays.asList(err)));
err.setCode("602");
assertTrue(((MarketoRESTClient) client).isAccessTokenExpired(Arrays.asList(err)));
}
Aggregations