Search in sources :

Example 6 with SyncResult

use of org.talend.components.marketo.runtime.client.rest.response.SyncResult 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());
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) MarketoException(org.talend.components.marketo.runtime.client.type.MarketoException) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Record(org.apache.avro.generic.GenericData.Record) IndexedRecord(org.apache.avro.generic.IndexedRecord) SyncResult(org.talend.components.marketo.runtime.client.rest.response.SyncResult) Test(org.junit.Test)

Aggregations

SyncResult (org.talend.components.marketo.runtime.client.rest.response.SyncResult)6 ArrayList (java.util.ArrayList)5 MarketoException (org.talend.components.marketo.runtime.client.type.MarketoException)5 JsonObject (com.google.gson.JsonObject)4 Record (org.apache.avro.generic.GenericData.Record)4 IndexedRecord (org.apache.avro.generic.IndexedRecord)4 Test (org.junit.Test)4 MarketoSyncResult (org.talend.components.marketo.runtime.client.type.MarketoSyncResult)4 SyncStatus (org.talend.components.marketo.runtime.client.rest.type.SyncStatus)3 LeadActivityRecord (org.talend.components.marketo.runtime.client.rest.type.LeadActivityRecord)2 LeadChangeRecord (org.talend.components.marketo.runtime.client.rest.type.LeadChangeRecord)2 ListRecord (org.talend.components.marketo.runtime.client.rest.type.ListRecord)2 MarketoError (org.talend.components.marketo.runtime.client.type.MarketoError)1