Search in sources :

Example 16 with TMarketoOutputProperties

use of org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties in project components by Talend.

the class MarketoSinkTest method testValidate.

@Test
public void testValidate() throws Exception {
    // 
    // output
    // 
    TMarketoOutputProperties oprops = new TMarketoOutputProperties("test");
    oprops.connection.setupProperties();
    oprops.connection.endpoint.setValue("http://ABC.mkto.com");
    oprops.connection.clientAccessId.setValue("fakeId");
    oprops.connection.secretKey.setValue("sekret");
    oprops.setupProperties();
    MarketoSink spy = spy(sink);
    spy.initialize(null, oprops);
    doReturn(oprops.connection).when(spy).getEffectiveConnection(any(RuntimeContainer.class));
    doReturn(new ValidationResult(Result.ERROR)).when(spy).validateConnection(any(MarketoProvideConnectionProperties.class));
    assertEquals(Result.ERROR, spy.validate(null).getStatus());
    doReturn(ValidationResult.OK).when(spy).validateConnection(any(MarketoProvideConnectionProperties.class));
    // 
    oprops.outputOperation.setValue(OutputOperation.syncMultipleLeads);
    spy.initialize(null, oprops);
    assertEquals(Result.OK, spy.validate(null).getStatus());
    // 
    oprops.outputOperation.setValue(OutputOperation.deleteLeads);
    spy.initialize(null, oprops);
    assertEquals(Result.OK, spy.validate(null).getStatus());
    // 
    oprops.outputOperation.setValue(OutputOperation.deleteCustomObjects);
    spy.initialize(null, oprops);
    assertEquals(Result.ERROR, spy.validate(null).getStatus());
    // 
    oprops.outputOperation.setValue(OutputOperation.syncCustomObjects);
    spy.initialize(null, oprops);
    assertEquals(Result.ERROR, spy.validate(null).getStatus());
    // 
    oprops.outputOperation.setValue(OutputOperation.deleteCustomObjects);
    oprops.customObjectName.setValue("co");
    spy.initialize(null, oprops);
    assertEquals(Result.OK, spy.validate(null).getStatus());
    // 
    oprops.outputOperation.setValue(OutputOperation.syncCustomObjects);
    oprops.customObjectName.setValue("co");
    spy.initialize(null, oprops);
    assertEquals(Result.OK, spy.validate(null).getStatus());
    // 
    // input
    // 
    TMarketoInputProperties iprops = new TMarketoInputProperties("test");
    iprops.connection.setupProperties();
    iprops.connection.endpoint.setValue("http://ABC.mkto.com");
    iprops.connection.clientAccessId.setValue("fakeId");
    iprops.connection.secretKey.setValue("sekret");
    iprops.setupProperties();
    spy.initialize(null, iprops);
    assertEquals(Result.ERROR, spy.validate(null).getStatus());
    // 
    iprops.inputOperation.setValue(InputOperation.getMultipleLeads);
    spy.initialize(null, iprops);
    assertEquals(Result.ERROR, spy.validate(null).getStatus());
    // 
    iprops.connection.apiMode.setValue(APIMode.SOAP);
    spy.initialize(null, iprops);
    assertEquals(Result.ERROR, spy.validate(null).getStatus());
    // 
    iprops.leadSelectorSOAP.setValue(LeadSelector.StaticListSelector);
    spy.initialize(null, iprops);
    assertEquals(Result.ERROR, spy.validate(null).getStatus());
    // 
    iprops.leadSelectorSOAP.setValue(LeadSelector.LeadKeySelector);
    iprops.leadKeyValues.setValue("test");
    spy.initialize(null, iprops);
    assertEquals(Result.OK, spy.validate(null).getStatus());
}
Also used : TMarketoOutputProperties(org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) MarketoProvideConnectionProperties(org.talend.components.marketo.MarketoProvideConnectionProperties) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 17 with TMarketoOutputProperties

use of org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties in project components by Talend.

the class MarketoSinkTest method testCreateWriteOperation.

@Test
public void testCreateWriteOperation() throws Exception {
    assertNotNull(new MarketoSink().createWriteOperation());
    sink.properties = new TMarketoListOperationProperties("test");
    assertTrue(sink.createWriteOperation() instanceof MarketoWriteOperation);
    sink.properties = new TMarketoOutputProperties("test");
    assertTrue(sink.createWriteOperation() instanceof MarketoWriteOperation);
}
Also used : TMarketoOutputProperties(org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties) TMarketoListOperationProperties(org.talend.components.marketo.tmarketolistoperation.TMarketoListOperationProperties) Test(org.junit.Test)

Aggregations

TMarketoOutputProperties (org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties)17 Before (org.junit.Before)9 TMarketoInputProperties (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)9 TMarketoListOperationProperties (org.talend.components.marketo.tmarketolistoperation.TMarketoListOperationProperties)7 Test (org.junit.Test)3 AuthenticationHeader (com.marketo.mktows.AuthenticationHeader)1 MktowsPort (com.marketo.mktows.MktowsPort)1 ObjectFactory (com.marketo.mktows.ObjectFactory)1 ParamsListMObjects (com.marketo.mktows.ParamsListMObjects)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 Schema (org.apache.avro.Schema)1 Field (org.apache.avro.Schema.Field)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)1 MarketoProvideConnectionProperties (org.talend.components.marketo.MarketoProvideConnectionProperties)1 SyncStatus (org.talend.components.marketo.runtime.client.rest.type.SyncStatus)1 ListOperationParameters (org.talend.components.marketo.runtime.client.type.ListOperationParameters)1 MarketoSyncResult (org.talend.components.marketo.runtime.client.type.MarketoSyncResult)1