use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoLeadClientTest method testListOperations.
@Test
public void testListOperations() throws Exception {
lprops.afterListOperation();
ListOperationParameters parms = new ListOperationParameters();
parms.setApiMode(REST.name());
parms.setListId(666123);
parms.setLeadIds(new Integer[] { 12345 });
//
doThrow(new MarketoException("REST", "error")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.addToList(parms);
assertFalse(mktoSR.isSuccess());
assertFalse(mktoSR.getErrorsString().isEmpty());
//
doReturn(getListOperationResult(false, "skipped")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.removeFromList(parms);
assertFalse(mktoSR.isSuccess());
assertNotNull(mktoSR.getErrorsString());
//
doReturn(getListOperationResult(true, "removed")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.removeFromList(parms);
assertTrue(mktoSR.isSuccess());
//
doReturn(getListOperationResult(true, "memberof")).when(client).executeGetRequest(eq(SyncResult.class));
mktoSR = client.isMemberOfList(parms);
assertTrue(mktoSR.isSuccess());
assertNotNull(mktoSR.getRecords().get(0));
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoSOAPClientTestIT 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(SOAP.name());
parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
parms.setLeadKeyValue(new String[] { createdLeads.get(10).toString() });
// 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());
assertTrue(Boolean.parseBoolean(r.getStatus()));
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoSOAPClientTestIT method testAddToListFail.
@Test
public void testAddToListFail() 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.setLeadKeyValue(new String[] { "12345" });
// first make sure to remove lead
MarketoSyncResult result;
List<SyncStatus> changes;
result = client.addToList(parms);
LOG.debug("result = {}.", result);
changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertFalse(Boolean.parseBoolean(r.getStatus()));
assertEquals("[20103] Lead Not Found.", r.getAvailableReason());
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoSOAPClientTestIT method testRemoveFromList.
@Test
public void testRemoveFromList() 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.setLeadKeyValue(new String[] { createdLeads.get(20).toString() });
// first subscribe lead
MarketoSyncResult result = client.addToList(parms);
List<SyncStatus> changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertTrue(Boolean.parseBoolean(r.getStatus()));
LOG.debug("r = {}.", r);
}
// then remove it
result = client.removeFromList(parms);
LOG.debug("result = {}.", result);
changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertTrue(Boolean.parseBoolean(r.getStatus()));
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters 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