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());
}
Aggregations