Search in sources :

Example 41 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoWriteOperationTest method testCreateWriter.

@Test
public void testCreateWriter() throws Exception {
    MarketoSink sink = new MarketoSink();
    TMarketoListOperationProperties plist = new TMarketoListOperationProperties("test");
    plist.init();
    TMarketoOutputProperties pout = new TMarketoOutputProperties("test");
    pout.init();
    TMarketoInputProperties pin = new TMarketoInputProperties("test");
    pin.init();
    sink.initialize(null, null);
    wop = new MarketoWriteOperation(sink);
    assertNull(wop.createWriter(null));
    sink.initialize(null, plist);
    wop = new MarketoWriteOperation(sink);
    assertEquals(MarketoListOperationWriter.class, wop.createWriter(null).getClass());
    sink.initialize(null, pout);
    wop = new MarketoWriteOperation(sink);
    assertEquals(MarketoOutputWriter.class, wop.createWriter(null).getClass());
    sink.initialize(null, pin);
    wop = new MarketoWriteOperation(sink);
    assertEquals(MarketoInputWriter.class, wop.createWriter(null).getClass());
}
Also used : TMarketoOutputProperties(org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties) TMarketoListOperationProperties(org.talend.components.marketo.tmarketolistoperation.TMarketoListOperationProperties) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Test(org.junit.Test)

Example 42 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoInputWriterTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    props.leadKeyValues.setValue("email");
    props.updateSchemaRelated();
    when(sink.getProperties()).thenReturn(props);
    wop = new MarketoWriteOperation(sink);
    writer = new MarketoInputWriter(wop, null);
    writer.properties = props;
    assertTrue(writer instanceof MarketoInputWriter);
    record = new Record(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
    record.put(1, "toto@toto.com");
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Record(org.apache.avro.generic.GenericData.Record) IndexedRecord(org.apache.avro.generic.IndexedRecord) Before(org.junit.Before)

Example 43 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties 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 44 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoInputReaderTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    source = mock(MarketoSource.class);
    source.initialize(null, props);
    when(source.getClientService(any(RuntimeContainer.class))).thenReturn(client);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    reader = (MarketoInputReader) source.createReader(null);
    assertTrue(reader instanceof MarketoInputReader);
    when(client.getLead(any(TMarketoInputProperties.class), any(String.class))).thenReturn(getFailedRecordResult("REST", "", "error"));
    when(client.getMultipleLeads(any(TMarketoInputProperties.class), any(String.class))).thenReturn(getFailedRecordResult("REST", "", "error"));
    when(client.getLeadActivity(any(TMarketoInputProperties.class), any(String.class))).thenReturn(getFailedRecordResult("REST", "", "error"));
    when(client.getLeadChanges(any(TMarketoInputProperties.class), any(String.class))).thenReturn(getFailedRecordResult("REST", "", "error"));
    when(client.describeCustomObject(any(TMarketoInputProperties.class))).thenReturn(getFailedRecordResult("REST", "", "error"));
    when(client.listCustomObjects(any(TMarketoInputProperties.class))).thenReturn(getFailedRecordResult("REST", "", "error"));
    when(client.getCustomObjects(any(TMarketoInputProperties.class), any(String.class))).thenReturn(getFailedRecordResult("REST", "", "error"));
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Before(org.junit.Before)

Example 45 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoInputReaderTest method testActivities.

@Test
public void testActivities() throws Exception {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    props.inputOperation.setValue(InputOperation.getLeadActivity);
    props.updateSchemaRelated();
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    when(client.getLeadActivity(any(TMarketoInputProperties.class), any(String.class))).thenReturn(getLeadRecordResult(false));
    reader = (MarketoInputReader) source.createReader(null);
    assertTrue(props.isApiREST());
    assertTrue(reader.start());
    assertNotNull(reader.getCurrent());
    assertTrue(reader.advance());
    assertNotNull(reader.getCurrent());
    // 
    props.setIncludeTypes.setValue(true);
    props.includeTypes.type.setValue(Arrays.asList("activity1", "activity2"));
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    reader = (MarketoInputReader) source.createReader(null);
    assertTrue(props.isApiREST());
    assertTrue(reader.start());
    assertNotNull(reader.getCurrent());
    assertTrue(reader.advance());
    assertNotNull(reader.getCurrent());
    assertFalse(reader.advance());
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Test(org.junit.Test)

Aggregations

TMarketoInputProperties (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)45 Test (org.junit.Test)25 Before (org.junit.Before)11 IndexedRecord (org.apache.avro.generic.IndexedRecord)10 TMarketoOutputProperties (org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties)9 TMarketoListOperationProperties (org.talend.components.marketo.tmarketolistoperation.TMarketoListOperationProperties)6 Date (java.util.Date)5 Schema (org.apache.avro.Schema)5 SimpleDateFormat (java.text.SimpleDateFormat)4 MarketoRecordResult (org.talend.components.marketo.runtime.client.type.MarketoRecordResult)4 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)2 MarketoRESTClient (org.talend.components.marketo.runtime.client.MarketoRESTClient)2 TMarketoBulkExecProperties (org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties)2 LeadSelector (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties.LeadSelector)2 NamedThing (org.talend.daikon.NamedThing)2 ValidationResult (org.talend.daikon.properties.ValidationResult)2 ValidationResultMutable (org.talend.daikon.properties.ValidationResultMutable)2 Gson (com.google.gson.Gson)1 AuthenticationHeader (com.marketo.mktows.AuthenticationHeader)1 MktowsPort (com.marketo.mktows.MktowsPort)1