use of org.talend.components.marketo.runtime.client.rest.type.SyncStatus in project components by Talend.
the class MarketoClientCustomObjectsTestIT method testDeleteCustomObjectsByDedupeFields.
@Test
public void testDeleteCustomObjectsByDedupeFields() throws Exception {
MarketoSyncResult rs = createCustomObjectRecords("");
assertTrue(rs.isSuccess());
//
oprops.customObjectName.setValue(TEST_CO_NAME_SMARTPHONE);
Schema s = //
SchemaBuilder.record("sn").fields().name(FIELD_CO_SMARTPHONE_MODEL).type().stringType().noDefault().endRecord();
List<IndexedRecord> records = new ArrayList<>();
IndexedRecord r1;
for (String m : TEST_SMARTPHONE_MODELS) {
r1 = new Record(s);
r1.put(0, m);
records.add(r1);
}
MarketoSource source = new MarketoSource();
oprops.customObjectDeleteBy.setValue(CustomObjectDeleteBy.dedupeFields);
source.initialize(null, oprops);
MarketoRESTClient client = (MarketoRESTClient) source.getClientService(null);
rs = client.deleteCustomObjects(oprops, records);
assertTrue(rs.isSuccess());
List<SyncStatus> changes = rs.getRecords();
assertEquals(TEST_SMARTPHONE_MODELS.length, changes.size());
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getSeq());
assertEquals(STATUS_DELETED, r.getStatus());
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.client.rest.type.SyncStatus in project components by Talend.
the class MarketoLeadClientTest method testSyncLead.
@Test
public void testSyncLead() throws Exception {
oprops.afterOutputOperation();
oprops.beforeMappingInput();
IndexedRecord record = new Record(MarketoConstants.getRESTOutputSchemaForSyncLead());
record.put(0, 12345);
record.put(1, "t@t.com");
//
doThrow(new MarketoException("REST", "error")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.syncLead(oprops, record);
assertFalse(mktoSR.isSuccess());
assertFalse(mktoSR.getErrorsString().isEmpty());
//
doReturn(new SyncResult()).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.syncLead(oprops, record);
assertFalse(mktoSR.isSuccess());
//
SyncResult sr = new SyncResult();
sr.setSuccess(true);
List<SyncStatus> ssr = new ArrayList<>();
SyncStatus ss = new SyncStatus();
ss.setStatus("created");
ss.setMarketoGUID("mkto-123456");
ss.setSeq(0);
ss.setId(12345);
ss.setErrorMessage("");
ssr.add(ss);
sr.setResult(ssr);
doReturn(sr).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.syncLead(oprops, record);
assertTrue(mktoSR.isSuccess());
assertTrue(mktoSR.getErrorsString().isEmpty());
}
use of org.talend.components.marketo.runtime.client.rest.type.SyncStatus in project components by Talend.
the class MarketoLeadClientTest method testDeleteLeads.
@Test
public void testDeleteLeads() throws Exception {
IndexedRecord record = new Record(MarketoConstants.getDeleteLeadsSchema());
record.put(0, 12345);
//
doThrow(new MarketoException("REST", "error")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.deleteLeads(new Integer[] { 12345 });
mktoSR = client.deleteLeads(Arrays.asList(record));
assertFalse(mktoSR.isSuccess());
assertFalse(mktoSR.getErrorsString().isEmpty());
//
doReturn(new SyncResult()).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.deleteLeads(new Integer[] { 12345 });
assertFalse(mktoSR.isSuccess());
//
SyncResult sr = new SyncResult();
sr.setSuccess(true);
List<SyncStatus> ssr = new ArrayList<>();
SyncStatus ss = new SyncStatus();
ss.setStatus("created");
ss.setMarketoGUID("mkto-123456");
ss.setSeq(0);
ss.setId(12345);
ss.setErrorMessage("");
ssr.add(ss);
sr.setResult(ssr);
doReturn(sr).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.deleteLeads(new Integer[] { 12345 });
assertTrue(mktoSR.isSuccess());
assertTrue(mktoSR.getErrorsString().isEmpty());
}
use of org.talend.components.marketo.runtime.client.rest.type.SyncStatus in project components by Talend.
the class MarketoLeadClientTest method getListOperationResult.
public SyncResult getListOperationResult(boolean isSuccess, String status) {
SyncResult result = new SyncResult();
List<SyncStatus> records = new ArrayList<>();
if (isSuccess) {
result.setSuccess(true);
SyncStatus ss = new SyncStatus();
ss.setSeq(0);
ss.setMarketoGUID("mkto-123456");
ss.setStatus(status);
ss.setErrorMessage("");
records.add(ss);
result.setResult(records);
} else {
result.setSuccess(false);
result.setErrors(Arrays.asList(new MarketoError("REST", "errorlist")));
}
return result;
}
use of org.talend.components.marketo.runtime.client.rest.type.SyncStatus in project components by Talend.
the class MarketoRuntimeTestBase method getFailedSyncResult.
public MarketoSyncResult getFailedSyncResult(boolean withSyncRecord) {
MarketoSyncResult mkto = new MarketoSyncResult();
mkto.setSuccess(false);
mkto.setErrors(Arrays.asList(new MarketoError("REST", "error")));
if (withSyncRecord) {
SyncStatus sts1 = new SyncStatus();
sts1.setId(12345);
sts1.setStatus("failed");
sts1.setMarketoGUID("mktoGUID");
sts1.setSeq(0);
List<SyncStatus> stl = new ArrayList<>();
stl.add(sts1);
mkto.setRecords(stl);
}
return mkto;
}
Aggregations