use of org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties in project components by Talend.
the class MarketoBulkExecReaderTest method setUp.
@Before
public void setUp() throws Exception {
TMarketoBulkExecProperties props = new TMarketoBulkExecProperties("test");
props.connection.setupProperties();
props.setupProperties();
client = mock(MarketoRESTClient.class);
when(client.bulkImport(any(TMarketoBulkExecProperties.class))).thenReturn(new MarketoRecordResult());
MarketoSource source = mock(MarketoSource.class);
source.initialize(null, props);
when(source.getClientService(any(RuntimeContainer.class))).thenReturn(client);
when(source.createReader(null)).thenReturn(new MarketoBulkExecReader(null, source, props));
reader = (MarketoBulkExecReader) source.createReader(null);
assertTrue(reader instanceof MarketoBulkExecReader);
}
use of org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties in project components by Talend.
the class MarketoRESTClientBulkExecTestIT method setUp.
@Before
public void setUp() throws Exception {
props = new TMarketoBulkExecProperties("test");
props.connection.setupProperties();
props.connection.endpoint.setValue(ENDPOINT_REST);
props.connection.clientAccessId.setValue(USERID_REST);
props.connection.secretKey.setValue(SECRETKEY_REST);
props.connection.setupLayout();
props.schemaInput.setupProperties();
props.schemaInput.setupLayout();
props.setupProperties();
props.setupLayout();
//
coCSV = getClass().getResource("/customobjects.csv").getPath();
leadCSV = getClass().getResource("/leads.csv").getPath();
downloadPath = getClass().getResource("/").getPath() + "logs";
Path dl = Paths.get(downloadPath);
if (!Files.exists(dl)) {
Files.createDirectory(dl);
}
}
use of org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties in project components by Talend.
the class MarketoSource method validate.
@Override
public ValidationResult validate(RuntimeContainer container) {
ValidationResultMutable vr = new ValidationResultMutable(super.validate(container));
if (vr.getStatus().equals(Result.ERROR)) {
return vr;
}
if (properties instanceof TMarketoInputProperties) {
TMarketoInputProperties p = (TMarketoInputProperties) properties;
boolean useSOAP = APIMode.SOAP.equals(properties.getConnectionProperties().apiMode.getValue());
// Validate dynamic schema if needed
Boolean isDynamic = AvroUtils.isIncludeAllFields(p.schemaInput.schema.getValue());
if (useSOAP) {
// no dynamic schema for SOAP !
if (isDynamic) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.soap.dynamicschema"));
return vr;
}
}
// getLead
if (p.inputOperation.getValue().equals(InputOperation.getLead)) {
if (p.leadKeyValue.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.leadkeyvalue"));
return vr;
}
}
// getMultipleLeads
if (p.inputOperation.getValue().equals(InputOperation.getMultipleLeads)) {
LeadSelector sel;
if (useSOAP) {
sel = p.leadSelectorSOAP.getValue();
} else {
sel = p.leadSelectorREST.getValue();
}
switch(sel) {
case LeadKeySelector:
if (p.leadKeyValues.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.leadkeyvalues"));
return vr;
}
break;
case StaticListSelector:
if (ListParam.STATIC_LIST_NAME.equals(p.listParam.getValue())) {
if (p.listParamListName.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.listparamvalue"));
return vr;
}
} else {
if (p.listParamListId.getValue() == null) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.listparamvalue"));
return vr;
}
}
break;
case LastUpdateAtSelector:
if (p.oldestUpdateDate.getValue().isEmpty() || p.latestUpdateDate.getValue().isEmpty() || isInvalidDate(p.oldestUpdateDate.getValue()) || isInvalidDate(p.latestUpdateDate.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.updatedates"));
return vr;
}
break;
}
}
// getLeadActivity
if (p.inputOperation.getValue().equals(InputOperation.getLeadActivity)) {
if (isDynamic) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
return vr;
}
if (useSOAP) {
if (p.leadKeyValue.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.leadkeyvalue"));
return vr;
}
} else {
if (p.sinceDateTime.getValue().isEmpty() || isInvalidDate(p.sinceDateTime.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.sincedatetime"));
return vr;
}
}
}
// getLeadChanges
if (p.inputOperation.getValue().equals(InputOperation.getLeadChanges)) {
if (isDynamic) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
return vr;
}
if (useSOAP) {
if (p.oldestCreateDate.getValue().isEmpty() || p.latestCreateDate.getValue().isEmpty() || isInvalidDate(p.oldestCreateDate.getValue()) || isInvalidDate(p.latestCreateDate.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.createdates"));
return vr;
}
} else {
if (p.sinceDateTime.getValue().isEmpty() || isInvalidDate(p.sinceDateTime.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.sincedatetime"));
return vr;
}
if (StringUtils.isEmpty(p.fieldList.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.fieldlist"));
return vr;
}
}
}
// ///////////////////
if (p.inputOperation.getValue().equals(InputOperation.CustomObject)) {
// get Action
if (p.customObjectAction.getValue().equals(CustomObjectAction.get)) {
if (p.customObjectName.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
return vr;
}
if (p.useCompoundKey.getValue()) {
if (p.compoundKey.size() == 0) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.customobject.compoundkey"));
return vr;
}
} else {
// filterType & filterValue
if (p.customObjectFilterType.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.customobject.filtertype"));
return vr;
}
if (p.customObjectFilterValues.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.customobject.filtervalues"));
return vr;
}
}
}
// list no checking...
if (p.customObjectAction.getValue().equals(CustomObjectAction.list)) {
if (isDynamic) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
return vr;
}
}
// describe
if (p.customObjectAction.getValue().equals(CustomObjectAction.describe)) {
if (isDynamic) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.operation.dynamicschema"));
return vr;
}
if (p.customObjectName.getValue().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
return vr;
}
}
}
}
// BulkExec
if (properties instanceof TMarketoBulkExecProperties) {
TMarketoBulkExecProperties p = (TMarketoBulkExecProperties) properties;
if (StringUtils.isEmpty(p.bulkFilePath.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.sink.bulk.bulkfilepath"));
return vr;
}
Path tmpPath = Paths.get(p.bulkFilePath.getValue());
if (!Files.exists(tmpPath)) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.sink.bulk.bulkfilepath.notexists"));
return vr;
}
if (StringUtils.isEmpty(p.logDownloadPath.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.sink.bulk.logdownloadpath"));
return vr;
}
tmpPath = Paths.get(p.logDownloadPath.getValue());
if (!Files.isDirectory(tmpPath)) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.sink.bulk.logdownloadpath"));
return vr;
}
if (p.bulkImportTo.getValue().equals(BulkImportTo.Leads)) {
if (StringUtils.isEmpty(p.lookupField.getValue().name())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.bulk.lookupfield"));
return vr;
}
} else {
if (StringUtils.isEmpty(p.customObjectName.getValue())) {
vr.setStatus(Result.ERROR);
vr.setMessage(messages.getMessage("error.validation.customobject.customobjectname"));
return vr;
}
}
}
return vr;
}
use of org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties in project components by Talend.
the class MarketoSourceTest method setUp.
@Before
public void setUp() throws Exception {
source = new MarketoSource();
//
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();
//
bulkProps = new TMarketoBulkExecProperties("test");
bulkProps.setupProperties();
bulkProps.connection.init();
}
Aggregations