Search in sources :

Example 21 with MarketoError

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

the class MarketoBulkExecReaderTest method testRetryOperationFailNonRecoverableErrror.

@Test
public void testRetryOperationFailNonRecoverableErrror() throws Exception {
    MarketoRecordResult mkto = new MarketoRecordResult();
    mkto.setErrors(Arrays.asList(new MarketoError("REST", "902", "Invalid operation")));
    when(client.bulkImport(any(TMarketoBulkExecProperties.class))).thenReturn(mkto);
    doReturn(false).when(client).isErrorRecoverable(any(List.class));
    reader.properties.dieOnError.setValue(false);
    assertFalse(reader.start());
    int result = (int) reader.getReturnValues().get(RETURN_NB_CALL);
    assertEquals(1, result);
}
Also used : List(java.util.List) TMarketoBulkExecProperties(org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) MarketoError(org.talend.components.marketo.runtime.client.type.MarketoError) Test(org.junit.Test)

Example 22 with MarketoError

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

the class MarketoLeadClientTest method getListOperationResult.

public SyncResult getListOperationResult(boolean isSuccess, String status) {
    SyncResult result = new SyncResult();
    List<SyncStatus> records = new ArrayList<>();
    if (isSuccess) {
        result.setSuccess(true);
        SyncStatus ss = new SyncStatus();
        ss.setSeq(0);
        ss.setMarketoGUID("mkto-123456");
        ss.setStatus(status);
        ss.setErrorMessage("");
        records.add(ss);
        result.setResult(records);
    } else {
        result.setSuccess(false);
        result.setErrors(Arrays.asList(new MarketoError("REST", "errorlist")));
    }
    return result;
}
Also used : SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) ArrayList(java.util.ArrayList) SyncResult(org.talend.components.marketo.runtime.client.rest.response.SyncResult) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) MarketoError(org.talend.components.marketo.runtime.client.type.MarketoError)

Example 23 with MarketoError

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

the class MarketoSOAPClientTest method testIsErrorRecoverable.

@Test
public void testIsErrorRecoverable() throws Exception {
    MarketoError error = new MarketoException("SOAP", "20016 Request Expired").toMarketoError();
    assertTrue(client.isErrorRecoverable(Arrays.asList(error)));
    for (String code : new String[] { "10001", "20011", "20023", "20024" }) {
        error = new MarketoException("SOAP", String.format("SOAP %s Concurrency Limit Exceeded", code)).toMarketoError();
        assertTrue(client.isErrorRecoverable(Arrays.asList(error)));
    }
    error = new MarketoException("SOAP", "404 Page not found").toMarketoError();
    assertFalse(client.isErrorRecoverable(Arrays.asList(error)));
}
Also used : MarketoException(org.talend.components.marketo.runtime.client.type.MarketoException) MarketoError(org.talend.components.marketo.runtime.client.type.MarketoError) Test(org.junit.Test)

Example 24 with MarketoError

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

the class MarketoRuntimeTestBase method getFailedRecordResult.

public static MarketoRecordResult getFailedRecordResult(String api, String code, String message) {
    MarketoRecordResult mkto = new MarketoRecordResult();
    mkto.setSuccess(false);
    mkto.setErrors(Arrays.asList(new MarketoError(api, code, message)));
    return mkto;
}
Also used : MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) MarketoError(org.talend.components.marketo.runtime.client.type.MarketoError)

Example 25 with MarketoError

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

the class MarketoRuntimeTestBase method getFailedSyncResult.

public MarketoSyncResult getFailedSyncResult(boolean withSyncRecord) {
    MarketoSyncResult mkto = new MarketoSyncResult();
    mkto.setSuccess(false);
    mkto.setErrors(Arrays.asList(new MarketoError("REST", "error")));
    if (withSyncRecord) {
        SyncStatus sts1 = new SyncStatus();
        sts1.setId(12345);
        sts1.setStatus("failed");
        sts1.setMarketoGUID("mktoGUID");
        sts1.setSeq(0);
        List<SyncStatus> stl = new ArrayList<>();
        stl.add(sts1);
        mkto.setRecords(stl);
    }
    return mkto;
}
Also used : SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) ArrayList(java.util.ArrayList) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) MarketoError(org.talend.components.marketo.runtime.client.type.MarketoError)

Aggregations

MarketoError (org.talend.components.marketo.runtime.client.type.MarketoError)27 MarketoRecordResult (org.talend.components.marketo.runtime.client.type.MarketoRecordResult)16 Test (org.junit.Test)12 MarketoException (org.talend.components.marketo.runtime.client.type.MarketoException)12 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 MalformedURLException (java.net.MalformedURLException)7 InvalidKeyException (java.security.InvalidKeyException)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)7 ParseException (java.text.ParseException)7 ArrayList (java.util.ArrayList)7 JAXBException (javax.xml.bind.JAXBException)7 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)7 WebServiceException (javax.xml.ws.WebServiceException)7 ComponentException (org.talend.components.api.exception.ComponentException)7 MarketoSyncResult (org.talend.components.marketo.runtime.client.type.MarketoSyncResult)6 ArrayOfString (com.marketo.mktows.ArrayOfString)5 List (java.util.List)4 Schema (org.apache.avro.Schema)4 SyncStatus (org.talend.components.marketo.runtime.client.rest.type.SyncStatus)4 TMarketoBulkExecProperties (org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties)4