use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoBulkExecReaderTest method testRetryOperationSuccess.
@Test
public void testRetryOperationSuccess() throws Exception {
IndexedRecord record = new GenericData.Record(MarketoConstants.getEmptySchema());
MarketoRecordResult mkto = new MarketoRecordResult();
mkto.setSuccess(true);
mkto.setRecords(Arrays.asList(record));
when(client.bulkImport(any(TMarketoBulkExecProperties.class))).thenReturn(mkto);
assertTrue(reader.start());
assertFalse(reader.advance());
int result = (int) reader.getReturnValues().get(RETURN_NB_CALL);
assertEquals(1, result);
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoResultTest method testToString.
@Test
public void testToString() throws Exception {
IndexedRecord ir = new Record(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
result = new MarketoRecordResult(true, "POS", 0, 0, Arrays.asList(ir));
String s = "MarketoRecordResult{requestId='', success=true, errors=null, recordCount=0, remainCount=0, " + "streamPosition='POS', records=[{\"id\": null, \"email\": null, \"firstName\": null, \"lastName\": " + "null, \"createdAt\": null, \"updatedAt\": null}]}";
assertEquals(s, result.toString());
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoResultTest method testMarketoResultConstruct.
@Test
public void testMarketoResultConstruct() {
result = new MarketoRecordResult();
assertEquals(emptyList(), result.getRecords());
assertEquals(0, result.getRecordCount());
assertEquals(0, result.getRemainCount());
assertEquals("", result.getStreamPosition());
assertEquals("", result.getRequestId());
assertFalse(result.isSuccess());
assertNotNull(result.getErrors());
assertEquals(0, result.getErrors().size());
result.setRecordCount(100);
result.setRemainCount(100);
result.setStreamPosition("100");
result.setRecords(new ArrayList<IndexedRecord>());
result.setRequestId("REST::666");
result.setSuccess(true);
result.setErrors(Arrays.asList(new MarketoError("REST")));
assertEquals(emptyList(), result.getRecords());
assertEquals(100, result.getRecordCount());
assertEquals(100, result.getRemainCount());
assertEquals("100", result.getStreamPosition());
assertEquals("REST::666", result.getRequestId());
assertTrue(result.isSuccess());
assertNotNull(result.getErrors());
result = new MarketoRecordResult("200", 200, 200, null);
assertEquals(Collections.emptyList(), result.getRecords());
assertEquals(200, result.getRecordCount());
assertEquals(200, result.getRemainCount());
assertEquals("200", result.getStreamPosition());
result.setErrors(Arrays.asList(new MarketoError("REST", "101", "error"), new MarketoError("error2")));
assertNotNull(result.getErrorsString());
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoInputReaderTest method testStart.
@Test
public void testStart() throws Exception {
MarketoRecordResult mkto = new MarketoRecordResult();
mkto.setSuccess(false);
mkto.setErrors(Arrays.asList(new MarketoError("REST", "error")));
when(client.bulkImport(any(TMarketoBulkExecProperties.class))).thenReturn(mkto);
when(client.getLead(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.getMultipleLeads(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.getLeadActivity(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.getLeadChanges(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.describeCustomObject(any(TMarketoInputProperties.class))).thenReturn(mkto);
when(client.listCustomObjects(any(TMarketoInputProperties.class))).thenReturn(mkto);
when(client.getCustomObjects(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
try {
assertFalse(reader.start());
fail("Should not be here");
} catch (Exception e) {
}
IndexedRecord record = new GenericData.Record(MarketoConstants.getEmptySchema());
mkto.setSuccess(true);
mkto.setRecords(Arrays.asList(record));
when(client.bulkImport(any(TMarketoBulkExecProperties.class))).thenReturn(mkto);
when(client.getLead(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.getMultipleLeads(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.getLeadActivity(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.getLeadChanges(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
when(client.describeCustomObject(any(TMarketoInputProperties.class))).thenReturn(mkto);
when(client.listCustomObjects(any(TMarketoInputProperties.class))).thenReturn(mkto);
when(client.getCustomObjects(any(TMarketoInputProperties.class), any(String.class))).thenReturn(mkto);
assertFalse(reader.start());
}
use of org.talend.components.marketo.runtime.client.type.MarketoRecordResult in project components by Talend.
the class MarketoSourceOrSink method getSchemaNames.
@Override
public List<NamedThing> getSchemaNames(RuntimeContainer container) throws IOException {
List<NamedThing> customObjects = new ArrayList<>();
MarketoClientServiceExtended client = (MarketoClientServiceExtended) getClientService(null);
TMarketoInputProperties ip = new TMarketoInputProperties("COSchemas");
ip.init();
ip.connection = properties.getConnectionProperties();
ip.inputOperation.setValue(InputOperation.CustomObject);
ip.customObjectAction.setValue(CustomObjectAction.list);
ip.customObjectNames.setValue("");
ip.schemaInput.schema.setValue(MarketoConstants.getCustomObjectDescribeSchema());
MarketoRecordResult r = client.listCustomObjects(ip);
for (IndexedRecord co : r.getRecords()) {
// name cannot be null
String name = co.get(0).toString();
Object displayName = co.get(1);
if (displayName == null) {
displayName = name;
}
customObjects.add(new SimpleNamedThing(name, displayName.toString()));
}
//
return customObjects;
}
Aggregations