use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class FieldSplitterMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("splitfield", "delimiter", "enclosure", "name", "id", "idrem", "type", "format", "group", "decimal", "currency", "length", "precision", "nullif", "ifnull", "trimtype");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("splitfield", "getSplitField");
getterMap.put("delimiter", "getDelimiter");
getterMap.put("enclosure", "getEnclosure");
getterMap.put("name", "getFieldName");
getterMap.put("id", "getFieldID");
getterMap.put("idrem", "getFieldRemoveID");
getterMap.put("type", "getFieldType");
getterMap.put("format", "getFieldFormat");
getterMap.put("group", "getFieldGroup");
getterMap.put("decimal", "getFieldDecimal");
getterMap.put("currency", "getFieldCurrency");
getterMap.put("length", "getFieldLength");
getterMap.put("precision", "getFieldPrecision");
getterMap.put("nullif", "getFieldNullIf");
getterMap.put("ifnull", "getFieldIfNull");
getterMap.put("trimtype", "getFieldTrimType");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("splitfield", "setSplitField");
setterMap.put("delimiter", "setDelimiter");
setterMap.put("enclosure", "setEnclosure");
setterMap.put("name", "setFieldName");
setterMap.put("id", "setFieldID");
setterMap.put("idrem", "setFieldRemoveID");
setterMap.put("type", "setFieldType");
setterMap.put("format", "setFieldFormat");
setterMap.put("group", "setFieldGroup");
setterMap.put("decimal", "setFieldDecimal");
setterMap.put("currency", "setFieldCurrency");
setterMap.put("length", "setFieldLength");
setterMap.put("precision", "setFieldPrecision");
setterMap.put("nullif", "setFieldNullIf");
setterMap.put("ifnull", "setFieldIfNull");
setterMap.put("trimtype", "setFieldTrimType");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
fieldLoadSaveValidatorAttributeMap.put("name", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("id", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("idrem", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaFactory.getAllValueMetaNames().length), 5));
fieldLoadSaveValidatorAttributeMap.put("format", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("group", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("decimal", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("currency", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("nullif", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("ifnull", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("trimtype", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaBase.getTrimTypeCodes().length), 5));
LoadSaveTester loadSaveTester = new LoadSaveTester(FieldSplitterMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class FilesToResultMetaTest method testStepMeta.
@Test
public void testStepMeta() throws KettleException {
List<String> attributes = Arrays.asList("filename_field", "file_type");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("filename_field", "getFilenameField");
getterMap.put("file_type", "getFileType");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("filename_field", "setFilenameField");
setterMap.put("file_type", "setFileType");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
fieldLoadSaveValidatorAttributeMap.put("file_type", new IntLoadSaveValidator(ResultFile.fileTypeCode.length));
LoadSaveTester loadSaveTester = new LoadSaveTester(FilesToResultMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class FixedInputMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("filename", "headerPresent", "lineWidth", "bufferSize", "lazyConversionActive", "lineFeedPresent", "runningInParallel", "fileType", "addResultFile", "encoding", "fieldDefinition");
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("fieldDefinition", new ArrayLoadSaveValidator<FixedFileInputField>(new FixedFileInputFieldLoadSaveValidator(), 5));
attrValidatorMap.put("fileType", new IntLoadSaveValidator(FixedInputMeta.fileTypeDesc.length));
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.FieldLoadSaveValidator 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();
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class FuzzyMatchMetaTest method setUp.
@Before
public void setUp() throws Exception {
List<String> attributes = Arrays.asList("value", "valueName", "algorithm", "lookupfield", "mainstreamfield", "outputmatchfield", "outputvaluefield", "caseSensitive", "minimalValue", "maximalValue", "separator", "closervalue");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("value", "getValue");
put("valueName", "getValueName");
put("algorithm", "getAlgorithmType");
put("lookupfield", "getLookupField");
put("mainstreamfield", "getMainStreamField");
put("outputmatchfield", "getOutputMatchField");
put("outputvaluefield", "getOutputValueField");
put("caseSensitive", "isCaseSensitive");
put("minimalValue", "getMinimalValue");
put("maximalValue", "getMaximalValue");
put("separator", "getSeparator");
put("closervalue", "isGetCloserValue");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("value", "setValue");
put("valueName", "setValueName");
put("algorithm", "setAlgorithmType");
put("lookupfield", "setLookupField");
put("mainstreamfield", "setMainStreamField");
put("outputmatchfield", "setOutputMatchField");
put("outputvaluefield", "setOutputValueField");
put("caseSensitive", "setCaseSensitive");
put("minimalValue", "setMinimalValue");
put("maximalValue", "setMaximalValue");
put("separator", "setSeparator");
put("closervalue", "setGetCloserValue");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 3);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("value", stringArrayLoadSaveValidator);
attrValidatorMap.put("valueName", stringArrayLoadSaveValidator);
attrValidatorMap.put("algorithm", new AlgorithmLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
// typeValidatorMap.put( int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator( new IntLoadSaveValidator(), 3 ) );
loadSaveTester = new LoadSaveTester(FuzzyMatchMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Aggregations