use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoRuntimeTestBase method getLeadRecordResult.
public static MarketoRecordResult getLeadRecordResult(boolean withRemainCount) {
MarketoRecordResult mkto = new MarketoRecordResult();
mkto.setSuccess(true);
IndexedRecord record1 = new GenericData.Record(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
IndexedRecord record2 = new GenericData.Record(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
// id
record1.put(0, 12345);
// email
record1.put(1, "eg@test.com");
record1.put(2, "Evanence");
record1.put(3, "valerian");
record1.put(4, new Date());
record1.put(5, new Date());
// id
record2.put(0, 12346);
// email
record2.put(1, "eg2@test.com");
record2.put(2, "Evanence2");
record2.put(3, "valerian2");
record2.put(4, new Date());
record2.put(5, new Date());
if (withRemainCount) {
mkto.setRemainCount(2);
mkto.setStreamPosition("streamposition");
} else {
mkto.setRemainCount(0);
}
mkto.setRecordCount(2);
mkto.setRecords(Arrays.asList(record1, record2));
return mkto;
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoSourceOrSinkTest method getDescribeCO.
public MarketoRecordResult getDescribeCO() {
MarketoRecordResult mkto = new MarketoRecordResult();
mkto.setSuccess(true);
IndexedRecord record = new Record(MarketoConstants.getCustomObjectDescribeSchema());
record.put(0, "car_c");
record.put(1, "car_c");
// dedupe
record.put(6, "[\"model\"]");
record.put(8, "[{\"displayName\":\"CreatedAt\",\"dataType\":\"datetime\",\"name\":\"createdAt\"," + // fields
"\"updateable\":false},{\"displayName\":\"MarketoGUID\",\"dataType\":\"string\",\"length\":36,\"name\":\"marketoGUID\",\"updateable\":false}]");
mkto.setRecords(Arrays.asList(record));
return mkto;
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoCustomObjectClientTest method testGetCustomObjects.
@Test
public void testGetCustomObjects() throws Exception {
iprops.customObjectAction.setValue(CustomObjectAction.get);
doThrow(new MarketoException("REST", "error")).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.getCustomObjects(iprops, null);
assertFalse(mktoRR.isSuccess());
assertFalse(mktoRR.getErrorsString().isEmpty());
//
doReturn(new MarketoRecordResult()).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.getCustomObjects(iprops, null);
assertFalse(mktoRR.isSuccess());
assertTrue(mktoRR.getErrorsString().isEmpty());
//
MarketoRecordResult mrr = new MarketoRecordResult();
mrr.setSuccess(true);
mrr.setRemainCount(0);
mrr.setRecordCount(1);
List<IndexedRecord> records = new ArrayList<>();
IndexedRecord record = new Record(MarketoConstants.getCustomObjectRecordSchema());
record.put(0, "mkto-123456");
record.put(1, 0);
record.put(2, new Date());
record.put(3, new Date());
records.add(record);
mrr.setRecords(records);
doReturn(mrr).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.getCustomObjects(iprops, null);
assertTrue(mktoRR.isSuccess());
assertTrue(mktoRR.getErrorsString().isEmpty());
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoCustomObjectClientTest method testDescribeCustomObject.
@Test
public void testDescribeCustomObject() throws Exception {
iprops.customObjectAction.setValue(CustomObjectAction.describe);
//
doThrow(new MarketoException("REST", "error")).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.describeCustomObject(iprops);
assertFalse(mktoRR.isSuccess());
assertFalse(mktoRR.getErrorsString().isEmpty());
//
doReturn(new MarketoRecordResult()).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.describeCustomObject(iprops);
assertFalse(mktoRR.isSuccess());
assertTrue(mktoRR.getErrorsString().isEmpty());
//
doReturn(getCustomObjectResult()).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.describeCustomObject(iprops);
assertTrue(mktoRR.isSuccess());
assertTrue(mktoRR.getErrorsString().isEmpty());
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoCustomObjectClientTest method testListCustomObjects.
@Test
public void testListCustomObjects() throws Exception {
iprops.customObjectAction.setValue(CustomObjectAction.list);
doThrow(new MarketoException("REST", "error")).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.listCustomObjects(iprops);
assertFalse(mktoRR.isSuccess());
assertFalse(mktoRR.getErrorsString().isEmpty());
//
doReturn(new MarketoRecordResult()).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.listCustomObjects(iprops);
assertFalse(mktoRR.isSuccess());
assertTrue(mktoRR.getErrorsString().isEmpty());
//
doReturn(getCustomObjectResult()).when(client).executeGetRequest(any(Schema.class));
mktoRR = client.listCustomObjects(iprops);
assertTrue(mktoRR.isSuccess());
assertTrue(mktoRR.getErrorsString().isEmpty());
}
Aggregations