use of org.apache.avro.generic.GenericData.Record 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.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoSOAPClientTest method testSyncLead.
@Test
public void testSyncLead() throws Exception {
doReturn(getSyncLeadResult()).when(port).syncLead(any(ParamsSyncLead.class), any(AuthenticationHeader.class), any(MktowsContextHeader.class));
oprops.afterOutputOperation();
oprops.beforeMappingInput();
mktoSR = client.syncLead(oprops, null);
assertNotNull(mktoSR);
assertFalse(mktoSR.isSuccess());
IndexedRecord record = new Record(MarketoConstants.getSOAPOutputSchemaForSyncLead());
record.put(0, 12345);
record.put(1, "t@t.com");
mktoSR = client.syncLead(oprops, record);
assertNotNull(mktoSR);
assertTrue(mktoSR.isSuccess());
//
doThrow(new RuntimeException("error")).when(port).syncLead(any(ParamsSyncLead.class), any(AuthenticationHeader.class), any(MktowsContextHeader.class));
mktoSR = client.syncLead(oprops, record);
assertNotNull(mktoSR);
assertFalse(mktoSR.isSuccess());
}
use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoCustomObjectClientTest method getCustomObjectResult.
public MarketoRecordResult getCustomObjectResult() {
MarketoRecordResult cor = new MarketoRecordResult();
cor.setSuccess(true);
List<IndexedRecord> cos = new ArrayList<>();
IndexedRecord co = new Record(MarketoConstants.getCustomObjectDescribeSchema());
co.put(0, "car_c");
co.put(1, "marketoGUID");
co.put(2, "Car");
co.put(3, "Car system");
co.put(4, new Date());
co.put(5, new Date());
co.put(6, "");
co.put(7, "{ \"brand\", \"model\" }");
co.put(8, "{}");
co.put(9, "{}");
cos.add(co);
cor.setRecords(cos);
return cor;
}
use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoCustomObjectClientTest method testDeleteCustomObjects.
@Test
public void testDeleteCustomObjects() throws Exception {
oprops.customObjectDeleteBy.setValue(CustomObjectDeleteBy.idField);
//
doThrow(new MarketoException("REST", "error")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
List<IndexedRecord> records = new ArrayList<>();
IndexedRecord record = new Record(MarketoConstants.getCustomObjectRecordSchema());
record.put(0, "mkto-123456");
records.add(record);
mktoSR = client.deleteCustomObjects(oprops, records);
assertFalse(mktoSR.isSuccess());
assertFalse(mktoSR.getErrorsString().isEmpty());
//
doReturn(new SyncResult()).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.deleteCustomObjects(oprops, records);
assertFalse(mktoSR.isSuccess());
//
doReturn(getListOperationResult(true, "deleted")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.deleteCustomObjects(oprops, records);
assertTrue(mktoSR.isSuccess());
assertTrue(mktoSR.getErrorsString().isEmpty());
}
use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoInputWriterTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
props = new TMarketoInputProperties("test");
props.connection.setupProperties();
props.setupProperties();
props.leadKeyValues.setValue("email");
props.updateSchemaRelated();
when(sink.getProperties()).thenReturn(props);
wop = new MarketoWriteOperation(sink);
writer = new MarketoInputWriter(wop, null);
writer.properties = props;
assertTrue(writer instanceof MarketoInputWriter);
record = new Record(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
record.put(1, "toto@toto.com");
}
Aggregations