use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class PrioritizeStreamsMetaTest method setUp.
@Before
public void setUp() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("stepName");
Map<String, String> getterMap = new HashMap<String, String>();
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("stepName", stringArrayLoadSaveValidator);
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class PropertyInputMetaTest method setUp.
@Before
public void setUp() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("encoding", "fileType", "includeFilename", "resetRowNumber", "resolvevaluevariable", "filenameField", "includeRowNumber", "rowNumberField", "rowLimit", "filefield", "isaddresult", "dynamicFilenameField", "includeIniSection", "iniSectionField", "section", "shortFileFieldName", "pathFieldName", "hiddenFieldName", "lastModificationTimeFieldName", "uriNameFieldName", "rootUriNameFieldName", "extensionFieldName", "sizeFieldName", "fileName", "fileMask", "excludeFileMask", "fileRequired", "includeSubFolders", "inputFields");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("encoding", "getEncoding");
put("fileType", "getFileType");
put("includeFilename", "includeFilename");
put("resetRowNumber", "resetRowNumber");
put("resolvevaluevariable", "isResolveValueVariable");
put("filenameField", "getFilenameField");
put("includeRowNumber", "includeRowNumber");
put("rowNumberField", "getRowNumberField");
put("rowLimit", "getRowLimit");
put("filefield", "isFileField");
put("isaddresult", "isAddResultFile");
put("dynamicFilenameField", "getDynamicFilenameField");
put("includeIniSection", "includeIniSection");
put("iniSectionField", "getINISectionField");
put("section", "getSection");
put("shortFileFieldName", "getShortFileNameField");
put("pathFieldName", "getPathField");
put("hiddenFieldName", "isHiddenField");
put("lastModificationTimeFieldName", "getLastModificationDateField");
put("uriNameFieldName", "getUriField");
put("rootUriNameFieldName", "getRootUriField");
put("extensionFieldName", "getExtensionField");
put("sizeFieldName", "getSizeField");
put("fileName", "getFileName");
put("fileMask", "getFileMask");
put("excludeFileMask", "getExcludeFileMask");
put("fileRequired", "getFileRequired");
put("includeSubFolders", "getIncludeSubFolders");
put("inputFields", "getInputFields");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("encoding", "setEncoding");
put("fileType", "setFileType");
put("includeFilename", "setIncludeFilename");
put("resetRowNumber", "setResetRowNumber");
put("resolvevaluevariable", "setResolveValueVariable");
put("filenameField", "setFilenameField");
put("includeRowNumber", "setIncludeRowNumber");
put("rowNumberField", "setRowNumberField");
put("rowLimit", "setRowLimit");
put("filefield", "setFileField");
put("isaddresult", "setAddResultFile");
put("dynamicFilenameField", "setDynamicFilenameField");
put("includeIniSection", "setIncludeIniSection");
put("iniSectionField", "setINISectionField");
put("section", "setSection");
put("shortFileFieldName", "setShortFileNameField");
put("pathFieldName", "setPathField");
put("hiddenFieldName", "setIsHiddenField");
put("lastModificationTimeFieldName", "setLastModificationDateField");
put("uriNameFieldName", "setUriField");
put("rootUriNameFieldName", "setRootUriField");
put("extensionFieldName", "setExtensionField");
put("sizeFieldName", "setSizeField");
put("fileName", "setFileName");
put("fileMask", "setFileMask");
put("excludeFileMask", "setExcludeFileMask");
put("fileRequired", "setFileRequired");
put("includeSubFolders", "setIncludeSubFolders");
put("inputFields", "setInputFields");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
FieldLoadSaveValidator<PropertyInputField[]> pifArrayLoadSaveValidator = new ArrayLoadSaveValidator<PropertyInputField>(new PropertyInputFieldLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fileName", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileRequired", stringArrayLoadSaveValidator);
attrValidatorMap.put("includeSubFolders", stringArrayLoadSaveValidator);
attrValidatorMap.put("inputFields", pifArrayLoadSaveValidator);
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
// typeValidatorMap.put( int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator( new IntLoadSaveValidator(), 1 ) );
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.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class RegexEvalMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("script", "matcher", "resultfieldname", "usevar", "allowcapturegroups", "replacefields", "canoneq", "caseinsensitive", "comment", "dotall", "multiline", "unicode", "unix", "fieldName", "fieldFormat", "fieldGroup", "fieldDecimal", "fieldCurrency", "fieldNullIf", "fieldIfNull", "fieldTrimType", "fieldLength", "fieldPrecision", "fieldType");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("script", "getScript");
put("matcher", "getMatcher");
put("resultfieldname", "getResultFieldName");
put("usevar", "isUseVariableInterpolationFlagSet");
put("allowcapturegroups", "isAllowCaptureGroupsFlagSet");
put("replacefields", "isReplacefields");
put("canoneq", "isCanonicalEqualityFlagSet");
put("caseinsensitive", "isCaseInsensitiveFlagSet");
put("comment", "isCommentFlagSet");
put("dotall", "isDotAllFlagSet");
put("multiline", "isMultilineFlagSet");
put("unicode", "isUnicodeFlagSet");
put("unix", "isUnixLineEndingsFlagSet");
put("fieldName", "getFieldName");
put("fieldFormat", "getFieldFormat");
put("fieldGroup", "getFieldGroup");
put("fieldDecimal", "getFieldDecimal");
put("fieldCurrency", "getFieldCurrency");
put("fieldNullIf", "getFieldNullIf");
put("fieldIfNull", "getFieldIfNull");
put("fieldTrimType", "getFieldTrimType");
put("fieldLength", "getFieldLength");
put("fieldPrecision", "getFieldPrecision");
put("fieldType", "getFieldType");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("script", "setScript");
put("matcher", "setMatcher");
put("resultfieldname", "setResultFieldName");
put("usevar", "setUseVariableInterpolationFlag");
put("allowcapturegroups", "setAllowCaptureGroupsFlag");
put("replacefields", "setReplacefields");
put("canoneq", "setCanonicalEqualityFlag");
put("caseinsensitive", "setCaseInsensitiveFlag");
put("comment", "setCommentFlag");
put("dotall", "setDotAllFlag");
put("multiline", "setMultilineFlag");
put("unicode", "setUnicodeFlag");
put("unix", "setUnixLineEndingsFlag");
put("fieldName", "setFieldName");
put("fieldFormat", "setFieldFormat");
put("fieldGroup", "setFieldGroup");
put("fieldDecimal", "setFieldDecimal");
put("fieldCurrency", "setFieldCurrency");
put("fieldNullIf", "setFieldNullIf");
put("fieldIfNull", "setFieldIfNull");
put("fieldTrimType", "setFieldTrimType");
put("fieldLength", "setFieldLength");
put("fieldPrecision", "setFieldPrecision");
put("fieldType", "setFieldType");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldFormat", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldGroup", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldDecimal", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldCurrency", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldNullIf", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldIfNull", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldTrimType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaBase.getTrimTypeCodes().length), 5));
attrValidatorMap.put("fieldLength", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
attrValidatorMap.put("fieldPrecision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 5));
attrValidatorMap.put("fieldType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 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.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class ReplaceStringMetaTest method testRoundTrips.
@Test
public void testRoundTrips() throws KettleException {
List<String> attributes = Arrays.asList("in_stream_name", "out_stream_name", "use_regex", "replace_string", "replace_by_string", "set_empty_string", "replace_field_by_string", "whole_word", "case_sensitive", "is_unicode");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("in_stream_name", "getFieldInStream");
getterMap.put("out_stream_name", "getFieldOutStream");
getterMap.put("use_regex", "getUseRegEx");
getterMap.put("replace_string", "getReplaceString");
getterMap.put("replace_by_string", "getReplaceByString");
getterMap.put("set_empty_string", "isSetEmptyString");
getterMap.put("replace_field_by_string", "getFieldReplaceByString");
getterMap.put("whole_word", "getWholeWord");
getterMap.put("case_sensitive", "getCaseSensitive");
getterMap.put("is_unicode", "isUnicode");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("in_stream_name", "setFieldInStream");
setterMap.put("out_stream_name", "setFieldOutStream");
setterMap.put("use_regex", "setUseRegEx");
setterMap.put("replace_string", "setReplaceString");
setterMap.put("replace_by_string", "setReplaceByString");
setterMap.put("set_empty_string", "setEmptyString");
setterMap.put("replace_field_by_string", "setFieldReplaceByString");
setterMap.put("whole_word", "setWholeWord");
setterMap.put("case_sensitive", "setCaseSensitive");
setterMap.put("is_unicode", "setIsUnicode");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
FieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
FieldLoadSaveValidator<int[]> useRegExArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.useRegExCode.length), 25);
FieldLoadSaveValidator<int[]> wholeWordArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.wholeWordCode.length), 25);
FieldLoadSaveValidator<int[]> caseSensitiveArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.caseSensitiveCode.length), 25);
FieldLoadSaveValidator<int[]> isUnicodeArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.isUnicodeCode.length), 25);
fieldLoadSaveValidatorAttributeMap.put("in_stream_name", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("out_stream_name", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("use_regex", useRegExArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("replace_string", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("replace_by_string", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("set_empty_string", booleanArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("replace_field_by_string", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("whole_word", wholeWordArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("case_sensitive", caseSensitiveArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("is_unicode", isUnicodeArrayLoadSaveValidator);
LoadSaveTester loadSaveTester = new LoadSaveTester(ReplaceStringMeta.class, attributes, getterMap, setterMap, 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 RestMetaTest method testLoadSaveRoundTrip.
@Test
public void testLoadSaveRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("applicationType", "method", "url", "urlInField", "dynamicMethod", "methodFieldName", "urlField", "bodyField", "httpLogin", "httpPassword", "proxyHost", "proxyPort", "preemptive", "trustStoreFile", "trustStorePassword", "headerField", "headerName", "parameterField", "parameterName", "matrixParameterField", "matrixParameterName", "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);
fieldLoadSaveValidatorAttributeMap.put("headerField", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("headerName", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("parameterField", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("parameterName", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("matrixParameterField", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("matrixParameterName", stringArrayLoadSaveValidator);
LoadSaveTester<RestMeta> loadSaveTester = new LoadSaveTester<RestMeta>(RestMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
Aggregations