Search in sources :

Example 11 with ListOperationParameters

use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.

the class MarketoSOAPClientTest method testListOperations.

@Test
public void testListOperations() throws Exception {
    doReturn(getListOperation(true, "added")).when(port).listOperation(any(ParamsListOperation.class), any(AuthenticationHeader.class));
    lprops.afterListOperation();
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(SOAP.name());
    parms.setListKeyValue("test_list");
    parms.setLeadKeyValue(new String[] { "12345" });
    mktoSR = client.addToList(parms);
    assertNotNull(mktoSR);
    assertTrue(mktoSR.isSuccess());
    doReturn(getListOperation(false, "skipped")).when(port).listOperation(any(ParamsListOperation.class), any(AuthenticationHeader.class));
    mktoSR = client.removeFromList(parms);
    assertTrue(mktoSR.isSuccess());
    assertNotNull(mktoSR.getErrorsString());
    doReturn(getListOperation(true, "memberof")).when(port).listOperation(any(ParamsListOperation.class), any(AuthenticationHeader.class));
    mktoSR = client.isMemberOfList(parms);
    assertTrue(mktoSR.isSuccess());
    assertNotNull(mktoSR.getRecords().get(0));
    doThrow(new RuntimeException("error")).when(port).listOperation(any(ParamsListOperation.class), any(AuthenticationHeader.class));
    mktoSR = client.isMemberOfList(parms);
    assertFalse(mktoSR.isSuccess());
    assertNotNull(mktoSR.getRecords());
}
Also used : ParamsListOperation(com.marketo.mktows.ParamsListOperation) AuthenticationHeader(com.marketo.mktows.AuthenticationHeader) ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) Test(org.junit.Test)

Aggregations

ListOperationParameters (org.talend.components.marketo.runtime.client.type.ListOperationParameters)11 Test (org.junit.Test)9 MarketoSyncResult (org.talend.components.marketo.runtime.client.type.MarketoSyncResult)9 SyncStatus (org.talend.components.marketo.runtime.client.rest.type.SyncStatus)8 MarketoSource (org.talend.components.marketo.runtime.MarketoSource)7 JsonObject (com.google.gson.JsonObject)1 AuthenticationHeader (com.marketo.mktows.AuthenticationHeader)1 ParamsListOperation (com.marketo.mktows.ParamsListOperation)1 ArrayList (java.util.ArrayList)1 Schema (org.apache.avro.Schema)1 Field (org.apache.avro.Schema.Field)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 SyncResult (org.talend.components.marketo.runtime.client.rest.response.SyncResult)1 MarketoException (org.talend.components.marketo.runtime.client.type.MarketoException)1 TMarketoOutputProperties (org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties)1