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());
}
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");
}
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());
}
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"));
}
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());
}
Aggregations