Search in sources :

Example 1 with ListOperationParameters

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

the class MarketoLeadClientTest method testListOperations.

@Test
public void testListOperations() throws Exception {
    lprops.afterListOperation();
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(REST.name());
    parms.setListId(666123);
    parms.setLeadIds(new Integer[] { 12345 });
    // 
    doThrow(new MarketoException("REST", "error")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
    mktoSR = client.addToList(parms);
    assertFalse(mktoSR.isSuccess());
    assertFalse(mktoSR.getErrorsString().isEmpty());
    // 
    doReturn(getListOperationResult(false, "skipped")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
    mktoSR = client.removeFromList(parms);
    assertFalse(mktoSR.isSuccess());
    assertNotNull(mktoSR.getErrorsString());
    // 
    doReturn(getListOperationResult(true, "removed")).when(client).executePostRequest(eq(SyncResult.class), any(JsonObject.class));
    mktoSR = client.removeFromList(parms);
    assertTrue(mktoSR.isSuccess());
    // 
    doReturn(getListOperationResult(true, "memberof")).when(client).executeGetRequest(eq(SyncResult.class));
    mktoSR = client.isMemberOfList(parms);
    assertTrue(mktoSR.isSuccess());
    assertNotNull(mktoSR.getRecords().get(0));
}
Also used : ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) MarketoException(org.talend.components.marketo.runtime.client.type.MarketoException) JsonObject(com.google.gson.JsonObject) SyncResult(org.talend.components.marketo.runtime.client.rest.response.SyncResult) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 2 with ListOperationParameters

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

the class MarketoSOAPClientTestIT method testAddToList.

/*
     * 
     * 
     * ListOperations
     * 
     * 
     */
@Test
public void testAddToList() throws Exception {
    MarketoSource source = new MarketoSource();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(SOAP.name());
    parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
    parms.setLeadKeyValue(new String[] { createdLeads.get(10).toString() });
    // first make sure to remove lead
    MarketoSyncResult result = client.removeFromList(parms);
    LOG.debug("result = {}.", result);
    List<SyncStatus> changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        LOG.debug("r = {}.", r);
    }
    // then add it
    result = client.addToList(parms);
    LOG.debug("result = {}.", result);
    changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertTrue(Boolean.parseBoolean(r.getStatus()));
        LOG.debug("r = {}.", r);
    }
}
Also used : ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 3 with ListOperationParameters

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

the class MarketoSOAPClientTestIT method testAddToListFail.

@Test
public void testAddToListFail() throws Exception {
    MarketoSource source = new MarketoSource();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(SOAP.name());
    parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
    parms.setLeadKeyValue(new String[] { "12345" });
    // first make sure to remove lead
    MarketoSyncResult result;
    List<SyncStatus> changes;
    result = client.addToList(parms);
    LOG.debug("result = {}.", result);
    changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertFalse(Boolean.parseBoolean(r.getStatus()));
        assertEquals("[20103] Lead Not Found.", r.getAvailableReason());
        LOG.debug("r = {}.", r);
    }
}
Also used : ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 4 with ListOperationParameters

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

the class MarketoSOAPClientTestIT method testRemoveFromList.

@Test
public void testRemoveFromList() throws Exception {
    MarketoSource source = new MarketoSource();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(SOAP.name());
    parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
    parms.setLeadKeyValue(new String[] { createdLeads.get(20).toString() });
    // first subscribe lead
    MarketoSyncResult result = client.addToList(parms);
    List<SyncStatus> changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertTrue(Boolean.parseBoolean(r.getStatus()));
        LOG.debug("r = {}.", r);
    }
    // then remove it
    result = client.removeFromList(parms);
    LOG.debug("result = {}.", result);
    changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertTrue(Boolean.parseBoolean(r.getStatus()));
        LOG.debug("r = {}.", r);
    }
}
Also used : ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) Test(org.junit.Test)

Example 5 with ListOperationParameters

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

the class MarketoRESTClientTestIT method testIsMemberOfList.

@Test
public void testIsMemberOfList() throws Exception {
    MarketoSource source = new MarketoSource();
    source.initialize(null, listProperties);
    MarketoClientService client = source.getClientService(null);
    // 
    ListOperationParameters parms = new ListOperationParameters();
    parms.setApiMode(APIMode.REST.name());
    parms.setListId(UNDX_TEST_LIST_SMALL_ID);
    parms.setLeadIds(new Integer[] { createdLeads.get(0), createdLeads.get(1), createdLeads.get(2) });
    // 
    MarketoSyncResult result = client.isMemberOfList(parms);
    LOG.debug("result = {}.", result);
    List<SyncStatus> changes = result.getRecords();
    assertTrue(changes.size() > 0);
    for (SyncStatus r : changes) {
        assertNotNull(r);
        assertNotNull(r.getId());
        assertEquals("memberof", r.getStatus());
        LOG.debug("r = {}.", r);
    }
}
Also used : ListOperationParameters(org.talend.components.marketo.runtime.client.type.ListOperationParameters) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) MarketoSource(org.talend.components.marketo.runtime.MarketoSource) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) 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