use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator 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<?>>());
}
use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class InsertUpdateMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
List<String> attributes = Arrays.asList("schemaName", "tableName", "databaseMeta", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "update", "commitSize", "updateBypassed");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("schemaName", "getSchemaName");
put("tableName", "getTableName");
put("databaseMeta", "getDatabaseMeta");
put("keyStream", "getKeyStream");
put("keyLookup", "getKeyLookup");
put("keyCondition", "getKeyCondition");
put("keyStream2", "getKeyStream2");
put("updateLookup", "getUpdateLookup");
put("updateStream", "getUpdateStream");
put("update", "getUpdate");
put("commitSize", "getCommitSizeVar");
put("updateBypassed", "isUpdateBypassed");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("schemaName", "setSchemaName");
put("tableName", "setTableName");
put("databaseMeta", "setDatabaseMeta");
put("keyStream", "setKeyStream");
put("keyLookup", "setKeyLookup");
put("keyCondition", "setKeyCondition");
put("keyStream2", "setKeyStream2");
put("updateLookup", "setUpdateLookup");
put("updateStream", "setUpdateStream");
put("update", "setUpdate");
put("commitSize", "setCommitSize");
put("updateBypassed", "setUpdateBypassed");
}
};
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("keyCondition", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyStream2", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateLookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
attrValidatorMap.put("update", new ArrayLoadSaveValidator<Boolean>(new BooleanLoadSaveValidator(), 5));
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 3));
loadSaveTester = new LoadSaveTester(InsertUpdateMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class JaninoMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("formula");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
FieldLoadSaveValidator<JaninoMetaFunction[]> janinoMetaFunctionArrayLoadSaveValidator = new ArrayLoadSaveValidator<JaninoMetaFunction>(new JaninoMetaFunctionFieldLoadSaveValidator(), 25);
fieldLoadSaveValidatorAttributeMap.put("formula", janinoMetaFunctionArrayLoadSaveValidator);
LoadSaveTester loadSaveTester = new LoadSaveTester(JaninoMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class ExcelInputMetaTest method testRepoRoundTripWithNullAttr.
@Test
public void testRepoRoundTripWithNullAttr() throws KettleException {
List<String> attributes = Arrays.asList("fileName", "fileMask", "excludeFileMask", "fileRequired", "includeSubFolders", "field", "sheetName", "startRow", "startColumn", "spreadSheetType", "fileField", "sheetField", "sheetRowNumberField", "rowNumberField", "shortFileFieldName", "extensionFieldName", "pathFieldName", "sizeFieldName", "hiddenFieldName", "lastModificationTimeFieldName", "uriNameFieldName", "rootUriNameFieldName");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("excludeFileMask", "getExludeFileMask");
put("shortFileFieldName", "getShortFileNameField");
put("extensionFieldName", "getExtensionField");
put("pathFieldName", "getPathField");
put("sizeFieldName", "getSizeField");
put("hiddenFieldName", "isHiddenField");
put("lastModificationTimeFieldName", "getLastModificationDateField");
put("uriNameFieldName", "getUriField");
put("rootUriNameFieldName", "getRootUriField");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("shortFileFieldName", "setShortFileNameField");
put("extensionFieldName", "setExtensionField");
put("pathFieldName", "setPathField");
put("sizeFieldName", "setSizeField");
put("hiddenFieldName", "setIsHiddenField");
put("lastModificationTimeFieldName", "setLastModificationDateField");
put("uriNameFieldName", "setUriField");
put("rootUriNameFieldName", "setRootUriField");
}
};
FieldLoadSaveValidator<String[]> nullStringArrayLoadSaveValidator = new NullStringArrayLoadSaveValidator();
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 1);
NullNameExcelInputArrayFieldLoadSaveValidator nullNameExcelInputArrayFieldLoadSaveValidator = new NullNameExcelInputArrayFieldLoadSaveValidator();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fileName", nullStringArrayLoadSaveValidator);
attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileRequired", stringArrayLoadSaveValidator);
attrValidatorMap.put("includeSubFolders", stringArrayLoadSaveValidator);
attrValidatorMap.put("sheetName", nullStringArrayLoadSaveValidator);
attrValidatorMap.put("field", nullNameExcelInputArrayFieldLoadSaveValidator);
attrValidatorMap.put("spreadSheetType", new SpreadSheetTypeFieldLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 1));
loadSaveTester = new LoadSaveTester(ExcelInputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
loadSaveTester.testRepoRoundTrip();
}
use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class FormulaMetaTest method testStepMeta.
@Test
public void testStepMeta() throws KettleException {
List<String> attributes = Arrays.asList("formula");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("formula", "getFormula");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("formula", "setFormula");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
FieldLoadSaveValidator<FormulaMetaFunction[]> formulaMetaFunctionArrayLoadSaveValidator = new ArrayLoadSaveValidator<FormulaMetaFunction>(new FormulaMetaFunctionFieldLoadSaveValidator(), 25);
fieldLoadSaveValidatorAttributeMap.put("formula", formulaMetaFunctionArrayLoadSaveValidator);
LoadSaveTester loadSaveTester = new LoadSaveTester(FormulaMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
Aggregations