use of org.talend.components.marketo.runtime.client.rest.response.DescribeFieldsResult in project components by Talend.
the class MarketoLeadClientTest method testGetAllLeadFields.
@Test
public void testGetAllLeadFields() throws Exception {
doThrow(new MarketoException("REST", "error")).when(client).executeGetRequest(DescribeFieldsResult.class);
List<Field> result = client.getAllLeadFields();
assertTrue(result.isEmpty());
//
doReturn(new DescribeFieldsResult()).when(client).executeGetRequest(DescribeFieldsResult.class);
result = client.getAllLeadFields();
assertTrue(result.isEmpty());
//
DescribeFieldsResult dfr = new DescribeFieldsResult();
dfr.setSuccess(true);
List<FieldDescription> fields = new ArrayList<>();
FieldDescription fd = new FieldDescription();
fd.setName("test");
fd.setDataType("string");
fd.setDisplayName("test");
fd.setId(124566);
fd.setLength(10);
fd.setUpdateable(true);
fields.add(fd);
dfr.setResult(fields);
doReturn(dfr).when(client).executeGetRequest(DescribeFieldsResult.class);
result = client.getAllLeadFields();
assertFalse(result.isEmpty());
}
use of org.talend.components.marketo.runtime.client.rest.response.DescribeFieldsResult in project components by Talend.
the class MarketoLeadClient method getAllLeadFields.
/*
*
* management func
*
*/
public List<Schema.Field> getAllLeadFields() {
current_uri = //
new StringBuilder(basicPath).append(//
"/v1/leads").append(//
API_PATH_URI_DESCRIBE).append(fmtParams(FIELD_ACCESS_TOKEN, accessToken, true));
List<Schema.Field> fields = new ArrayList<>();
try {
LOG.debug("describeLead {}.", current_uri);
DescribeFieldsResult rs = (DescribeFieldsResult) executeGetRequest(DescribeFieldsResult.class);
if (!rs.isSuccess()) {
return fields;
}
//
for (FieldDescription d : rs.getResult()) {
fields.add(d.toAvroField());
}
} catch (MarketoException e) {
LOG.error("describeLeadFields error: {}.", e.toString());
}
return fields;
}
Aggregations