use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.
the class RssInputMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("includeRowNumber", "rowNumberField", "includeUrl", "urlField", "rowLimit", "readfrom", "urlInField", "urlFieldname", "url", "inputFields");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("includeRowNumber", "includeRowNumber");
put("rowNumberField", "getRowNumberField");
put("includeUrl", "includeUrl");
put("urlField", "geturlField");
put("rowLimit", "getRowLimit");
put("readfrom", "getReadFrom");
put("urlInField", "urlInField");
put("urlFieldname", "getUrlFieldname");
put("url", "getUrl");
put("inputFields", "getInputFields");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("includeRowNumber", "setIncludeRowNumber");
put("rowNumberField", "setRowNumberField");
put("includeUrl", "setIncludeUrl");
put("urlField", "seturlField");
put("rowLimit", "setRowLimit");
put("readfrom", "setReadFrom");
put("urlInField", "seturlInField");
put("urlFieldname", "setUrlFieldname");
put("url", "setUrl");
put("inputFields", "setInputFields");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
FieldLoadSaveValidator<RssInputField[]> rssInputFieldArrayLoadSaveValidator = new ArrayLoadSaveValidator<RssInputField>(new RssInputFieldLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("url", stringArrayLoadSaveValidator);
attrValidatorMap.put("inputFields", rssInputFieldArrayLoadSaveValidator);
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this);
}
use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.
the class StreamLookupMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("inputSorted", "memoryPreservationActive", "usingSortedList", "usingIntegerPair", "keystream", "keylookup", "value", "valueName", "valueDefault", "valueDefaultType");
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("keystream", stringArrayLoadSaveValidator);
attrValidatorMap.put("keylookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("value", stringArrayLoadSaveValidator);
attrValidatorMap.put("valueName", stringArrayLoadSaveValidator);
attrValidatorMap.put("valueDefault", stringArrayLoadSaveValidator);
attrValidatorMap.put("valueDefaultType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(7), 5));
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), new HashMap<String, String>(), new HashMap<String, String>(), attrValidatorMap, typeValidatorMap, this);
}
use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.
the class ElasticSearchBulkMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("index", "type", "batchSize", "timeout", "timeoutUnit", "isJson", "jsonField", "idOutputField", "idField", "overwriteIfExists", "useOutput", "stopOnError", "fields", "servers", "settings");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("index", "getIndex");
getterMap.put("type", "getType");
getterMap.put("batchSize", "getBatchSize");
getterMap.put("timeout", "getTimeOut");
getterMap.put("timeoutUnit", "getTimeoutUnit");
getterMap.put("isJson", "isJsonInsert");
getterMap.put("jsonField", "getJsonField");
getterMap.put("idOutputField", "getIdOutField");
getterMap.put("idField", "getIdInField");
getterMap.put("overwriteIfExists", "isOverWriteIfSameId");
getterMap.put("useOutput", "isUseOutput");
getterMap.put("stopOnError", "isStopOnError");
getterMap.put("fields", "getFieldsMap");
getterMap.put("servers", "getServers");
getterMap.put("settings", "getSettingsMap");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("index", "setIndex");
setterMap.put("type", "setType");
setterMap.put("batchSize", "setBatchSize");
setterMap.put("timeout", "setTimeOut");
setterMap.put("timeoutUnit", "setTimeoutUnit");
setterMap.put("isJson", "setJsonInsert");
setterMap.put("jsonField", "setJsonField");
setterMap.put("idOutputField", "setIdOutField");
setterMap.put("idField", "setIdInField");
setterMap.put("overwriteIfExists", "setOverWriteIfSameId");
setterMap.put("useOutput", "setUseOutput");
setterMap.put("stopOnError", "setStopOnError");
setterMap.put("fields", "setFieldsMap");
setterMap.put("servers", "setServers");
setterMap.put("settings", "setSettingsMap");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
fieldLoadSaveValidatorAttributeMap.put("fields", new MapLoadSaveValidator<String, String>(new StringLoadSaveValidator(), new StringLoadSaveValidator()));
fieldLoadSaveValidatorAttributeMap.put("settings", new MapLoadSaveValidator<String, String>(new StringLoadSaveValidator(), new StringLoadSaveValidator()));
fieldLoadSaveValidatorAttributeMap.put("servers", new ListLoadSaveValidator<ElasticSearchBulkMeta.Server>(new FieldLoadSaveValidator<ElasticSearchBulkMeta.Server>() {
Random rand = new Random();
@Override
public ElasticSearchBulkMeta.Server getTestObject() {
ElasticSearchBulkMeta.Server r = new ElasticSearchBulkMeta.Server();
r.address = rand.nextLong() + "";
r.port = rand.nextInt();
return r;
}
@Override
public boolean validateTestObject(ElasticSearchBulkMeta.Server testObject, Object actual) {
ElasticSearchBulkMeta.Server ac = (ElasticSearchBulkMeta.Server) actual;
return ac.address.equals(testObject.address) && ac.port == testObject.port;
}
}));
fieldLoadSaveValidatorTypeMap.put(TimeUnit.class.getCanonicalName(), new TimeUnitFieldLoadSaveValidator());
LoadSaveTester loadSaveTester = new LoadSaveTester(ElasticSearchBulkMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, fieldLoadSaveValidatorTypeMap);
loadSaveTester.testRepoRoundTrip();
loadSaveTester.testXmlRoundTrip();
}
use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.
the class GroupByMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("passAllRows", "directory", "prefix", "aggregateIgnored", "aggregateIgnoredField", "addingLineNrInGroup", "lineNrInGroupField", "alwaysGivingBackOneRow", "groupField", "aggregateField", "subjectField", "aggregateType", "valueField");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("passAllRows", "passAllRows");
}
};
Map<String, String> setterMap = new HashMap<String, String>();
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("groupField", stringArrayLoadSaveValidator);
attrValidatorMap.put("aggregateField", stringArrayLoadSaveValidator);
attrValidatorMap.put("subjectField", stringArrayLoadSaveValidator);
attrValidatorMap.put("valueField", stringArrayLoadSaveValidator);
attrValidatorMap.put("aggregateType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(GroupByMeta.typeGroupCode.length), 5));
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this);
}
use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.
the class HTTPPOSTMetaTest method testLoadSaveRoundTrip.
@Before
public void testLoadSaveRoundTrip() throws KettleException {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("postAFile", "encoding", "url", "urlInField", "urlField", "requestEntity", "httpLogin", "httpPassword", "proxyHost", "proxyPort", "socketTimeout", "connectionTimeout", "closeIdleConnectionsTime", "argumentField", "argumentParameter", "argumentHeader", "queryField", "queryParameter", "fieldName", "resultCodeFieldName", "responseTimeFieldName", "responseHeaderFieldName");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
// Arrays need to be consistent length
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
FieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
fieldLoadSaveValidatorAttributeMap.put("argumentField", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("argumentParameter", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("argumentHeader", booleanArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("queryField", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("queryParameter", stringArrayLoadSaveValidator);
loadSaveTester = new LoadSaveTester(HTTPPOSTMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
}
Aggregations