use of org.talend.components.marketo.runtime.client.rest.response.StaticListResult in project components by Talend.
the class MarketoLeadClientTest method testGetListIdByName.
@Test
public void testGetListIdByName() throws Exception {
doReturn(null).when(client).executeGetRequest(StaticListResult.class);
try {
client.getListIdByName("test_list");
fail("Should not be here");
} catch (MarketoException e) {
}
StaticListResult rr = new StaticListResult();
rr.setSuccess(true);
ListRecord lr = new ListRecord();
lr.setId(666);
rr.setResult(Arrays.asList(lr));
doReturn(rr).when(client).executeGetRequest(StaticListResult.class);
assertEquals(Integer.valueOf(666), client.getListIdByName("test_list"));
}
use of org.talend.components.marketo.runtime.client.rest.response.StaticListResult in project components by Talend.
the class MarketoLeadClient method getListIdByName.
public Integer getListIdByName(String listName) throws MarketoException {
current_uri = //
new StringBuilder(basicPath).append(//
API_PATH_LISTS_JSON).append(//
fmtParams(FIELD_ACCESS_TOKEN, accessToken, true)).append(fmtParams(FIELD_NAME, listName));
StaticListResult getResponse = (StaticListResult) executeGetRequest(StaticListResult.class);
if (getResponse == null) {
throw new MarketoException(REST, messages.getMessage("error.response.null"));
}
if (!getResponse.isSuccess()) {
throw new MarketoException(REST, getResponse.getErrors().toString());
}
if (getResponse.getResult().isEmpty()) {
throw new MarketoException(REST, "No list match `" + listName + "`.");
}
return getResponse.getResult().get(0).getId();
}
Aggregations