use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.
the class ExcelInputMetaTest method testSerialization.
@Test
public void testSerialization() 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[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fileName", stringArrayLoadSaveValidator);
attrValidatorMap.put("sheetName", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileRequired", stringArrayLoadSaveValidator);
attrValidatorMap.put("includeSubFolders", stringArrayLoadSaveValidator);
attrValidatorMap.put("field", new ArrayLoadSaveValidator<ExcelInputField>(new ExcelInputFieldLoadSaveValidator(), 5));
attrValidatorMap.put("spreadSheetType", new SpreadSheetTypeFieldLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
loadSaveTester = new LoadSaveTester(ExcelInputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.
the class FieldsChangeSequenceMetaTest method testStepMeta.
@Test
public void testStepMeta() throws KettleException {
List<String> attributes = Arrays.asList("start", "increment", "resultfieldName", "name");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("start", "getStart");
getterMap.put("increment", "getIncrement");
getterMap.put("resultfieldName", "getResultFieldName");
getterMap.put("name", "getFieldName");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("start", "setStart");
setterMap.put("increment", "setIncrement");
setterMap.put("resultfieldName", "setResultFieldName");
setterMap.put("name", "setFieldName");
LoadSaveTester loadSaveTester = new LoadSaveTester(FieldsChangeSequenceMeta.class, attributes, getterMap, setterMap);
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.
the class FileExistsMetaTest method testStepMeta.
@Test
public void testStepMeta() throws KettleException {
List<String> attributes = Arrays.asList("filenamefield", "resultfieldname", "includefiletype", "filetypefieldname", "addresultfilenames");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("filenamefield", "getDynamicFilenameField");
getterMap.put("resultfieldname", "getResultFieldName");
getterMap.put("includefiletype", "includeFileType");
getterMap.put("filetypefieldname", "getFileTypeFieldName");
getterMap.put("addresultfilenames", "addResultFilenames");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("filenamefield", "setDynamicFilenameField");
setterMap.put("resultfieldname", "setResultFieldName");
setterMap.put("includefiletype", "setincludeFileType");
setterMap.put("filetypefieldname", "setFileTypeFieldName");
setterMap.put("addresultfilenames", "setaddResultFilenames");
LoadSaveTester loadSaveTester = new LoadSaveTester(FileExistsMeta.class, attributes, getterMap, setterMap);
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.
the class TextFileInputMetaLoadSaveTest method setUp.
@Before
public void setUp() throws Exception {
List<String> commonAttributes = Arrays.asList("errorCountField", "errorFieldsField", "errorTextField", "length");
List<String> xmlAttributes = Collections.emptyList();
List<String> repoAttributes = Collections.emptyList();
Map<String, String> getters = new HashMap<>();
getters.put("header", "hasHeader");
getters.put("footer", "hasFooter");
getters.put("noEmptyLines", "noEmptyLines");
getters.put("includeFilename", "includeFilename");
getters.put("includeRowNumber", "includeRowNumber");
getters.put("errorFilesExtension", "getErrorLineFilesExtension");
getters.put("isaddresult", "isAddResultFile");
getters.put("shortFileFieldName", "getShortFileNameField");
getters.put("pathFieldName", "getPathField");
getters.put("hiddenFieldName", "isHiddenField");
getters.put("lastModificationTimeFieldName", "getLastModificationDateField");
getters.put("uriNameFieldName", "getUriField");
getters.put("rootUriNameFieldName", "getRootUriField");
getters.put("extensionFieldName", "getExtensionField");
getters.put("sizeFieldName", "getSizeField");
Map<String, String> setters = new HashMap<>();
setters.put("fileName", "setFileNameForTest");
setters.put("errorFilesExtension", "setErrorLineFilesExtension");
setters.put("isaddresult", "setAddResultFile");
setters.put("shortFileFieldName", "setShortFileNameField");
setters.put("pathFieldName", "setPathField");
setters.put("hiddenFieldName", "setIsHiddenField");
setters.put("lastModificationTimeFieldName", "setLastModificationDateField");
setters.put("uriNameFieldName", "setUriField");
setters.put("rootUriNameFieldName", "setRootUriField");
setters.put("extensionFieldName", "setExtensionField");
setters.put("sizeFieldName", "setSizeField");
Map<String, FieldLoadSaveValidator<?>> attributeValidators = Collections.emptyMap();
Map<String, FieldLoadSaveValidator<?>> typeValidators = new HashMap<>();
typeValidators.put(TextFileFilter[].class.getCanonicalName(), new ArrayLoadSaveValidator<>(new TextFileFilterValidator()));
typeValidators.put(BaseFileField[].class.getCanonicalName(), new ArrayLoadSaveValidator<>(new TextFileInputFieldValidator()));
assertTrue(!commonAttributes.isEmpty() || !(xmlAttributes.isEmpty() || repoAttributes.isEmpty()));
tester = new LoadSaveTester(TextFileInputMeta.class, commonAttributes, xmlAttributes, repoAttributes, getters, setters, attributeValidators, typeValidators);
}
use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.
the class FilterRowsMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("condition", "send_true_to", "send_false_to");
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("condition", new ConditionLoadSaveValidator());
attrValidatorMap.put("trueStepName", new StringLoadSaveValidator());
attrValidatorMap.put("falseStepname", new StringLoadSaveValidator());
getterMap.put("send_true_to", "getTrueStepname");
setterMap.put("send_true_to", "setTrueStepname");
getterMap.put("send_false_to", "getFalseStepname");
setterMap.put("send_false_to", "setFalseStepname");
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Aggregations