use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoSOAPClientTest method testSyncMultipleLeads.
@Test
public void testSyncMultipleLeads() throws Exception {
doReturn(getSyncMultipleLeadsResult()).when(port).syncMultipleLeads(any(ParamsSyncMultipleLeads.class), any(AuthenticationHeader.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.syncMultipleLeads(oprops, Arrays.asList(record));
assertNotNull(mktoSR);
assertTrue(mktoSR.isSuccess());
//
doThrow(new RuntimeException("error")).when(port).syncMultipleLeads(any(ParamsSyncMultipleLeads.class), any(AuthenticationHeader.class));
mktoSR = client.syncMultipleLeads(oprops, Arrays.asList(record));
assertNotNull(mktoSR);
assertFalse(mktoSR.isSuccess());
}
use of org.apache.avro.generic.GenericData.Record 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.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoCustomObjectClientTest method testSyncCustomObjects.
@Test
public void testSyncCustomObjects() throws Exception {
oprops.customObjectSyncAction.setValue(CustomObjectSyncAction.createOrUpdate);
oprops.customObjectDedupeBy.setValue("marketoGUID");
//
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.syncCustomObjects(oprops, records);
assertFalse(mktoSR.isSuccess());
assertFalse(mktoSR.getErrorsString().isEmpty());
//
doReturn(new SyncResult()).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.syncCustomObjects(oprops, records);
assertFalse(mktoSR.isSuccess());
//
doReturn(getListOperationResult(true, "deleted")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
mktoSR = client.syncCustomObjects(oprops, records);
assertTrue(mktoSR.isSuccess());
assertTrue(mktoSR.getErrorsString().isEmpty());
}
use of org.apache.avro.generic.GenericData.Record 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.apache.avro.generic.GenericData.Record 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());
}
Aggregations