use of org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator in project pentaho-kettle by pentaho.
the class JobEntryEvalTableContentLoadSaveTest method createAttributeValidatorsMap.
@Override
protected Map<String, FieldLoadSaveValidator<?>> createAttributeValidatorsMap() {
Map<String, FieldLoadSaveValidator<?>> validators = new HashMap<String, FieldLoadSaveValidator<?>>();
validators.put("successCondition", new IntLoadSaveValidator(JobEntryEvalTableContent.successConditionsCode.length));
return validators;
}
use of org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator in project pentaho-kettle by pentaho.
the class TextFileInputMetaInjectionTest method createGeneratorsMapping.
private static Map<TextFileInputMetaInjection.Entry, Generator<?>> createGeneratorsMapping() {
Map<TextFileInputMetaInjection.Entry, Generator<?>> generators = new EnumMap<TextFileInputMetaInjection.Entry, Generator<?>>(TextFileInputMetaInjection.Entry.class);
Generator<String> stringGenerator = new ValidatorAdapter<String>(new StringLoadSaveValidator());
List<TextFileInputMetaInjection.Entry> stringEntries = Arrays.asList(FILE_TYPE, SEPARATOR, ENCLOSURE, ESCAPE_CHAR, COMPRESSION_TYPE, FILENAME_FIELD, ROW_NUMBER_FIELD, FILE_FORMAT, ENCODING, ACCEPT_FILE_STEP, ACCEPT_FILE_FIELD, FILE_SHORT_FILE_FIELDNAME, FILE_PATH_FIELDNAME, FILE_LAST_MODIFICATION_FIELDNAME, FILE_URI_FIELDNAME, FILE_EXTENSION_FIELDNAME, FILE_SIZE_FIELDNAME, FILE_ERROR_FIELD, FILE_ERROR_MESSAGE_FIELD, ERROR_COUNT_FIELD, ERROR_FIELDS_FIELD, ERROR_TEXT_FIELD, WARNING_FILES_TARGET_DIR, WARNING_FILES_EXTENTION, ERROR_FILES_TARGET_DIR, ERROR_FILES_EXTENTION, LINE_NR_FILES_TARGET_DIR, LINE_NR_FILES_EXTENTION);
for (TextFileInputMetaInjection.Entry entry : stringEntries) {
generators.put(entry, stringGenerator);
}
Generator<String> intGenerator = new ValidatorAdapter<Integer>(new IntLoadSaveValidator());
List<TextFileInputMetaInjection.Entry> intEntries = Arrays.asList(NR_HEADER_LINES, NR_FOOTER_LINES, NR_WRAPS, NR_DOC_HEADER_LINES, NR_LINES_PER_PAGE, ROW_LIMIT);
for (TextFileInputMetaInjection.Entry entry : intEntries) {
generators.put(entry, intGenerator);
}
Generator<String> yesNoGenerator = new YesNoGenerator();
List<TextFileInputMetaInjection.Entry> yesNoEntries = Arrays.asList(BREAK_IN_ENCLOSURE, HEADER_PRESENT, HAS_FOOTER, HAS_WRAPPED_LINES, HAS_PAGED_LAYOUT, NO_EMPTY_LINES, INCLUDE_FILENAME, INCLUDE_ROW_NUMBER, ROW_NUMBER_BY_FILE, DATE_FORMAT_LENIENT, ACCEPT_FILE_NAMES, PASS_THROUGH_FIELDS, ADD_FILES_TO_RESULT, FILE_HIDDEN_FIELDNAME, SKIP_BAD_FILES, IGNORE_ERRORS, ERROR_LINES_SKIPPED);
for (TextFileInputMetaInjection.Entry entry : yesNoEntries) {
generators.put(entry, yesNoGenerator);
}
generators.put(DATE_FORMAT_LOCALE, new Constant<String>("en"));
return generators;
}
use of org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator in project pentaho-kettle by pentaho.
the class ExcelOutputMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("headerFontName", "headerFontSize", "headerFontBold", "headerFontItalic", "headerFontUnderline", "headerFontOrientation", "headerFontColor", "headerBackGroundColor", "headerRowHeight", "headerAlignment", "headerImage", "rowFontName", "rowFontSize", "rowFontColor", "rowBackGroundColor", "fileName", "extension", "password", "headerEnabled", "footerEnabled", "splitEvery", "stepNrInFilename", "dateInFilename", "addToResultFiles", "sheetProtected", "timeInFilename", "templateEnabled", "templateFileName", "templateAppend", "sheetname", "useTempFiles", "tempDirectory", "encoding", "append", "doNotOpenNewFileInit", "createParentFolder", "specifyFormat", "dateTimeFormat", "autoSizeColumns", "nullBlank", "outputFields");
// Note - newline (get/set) doesn't appear to be used or persisted. So, it's not included in the load/save tester.
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("sheetProtected", "setProtectSheet");
put("nullBlank", "setNullIsBlank");
}
};
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("outputFields", new ArrayLoadSaveValidator<ExcelField>(new ExcelFieldLoadSaveValidator(), 5));
attrValidatorMap.put("headerFontName", new IntLoadSaveValidator(ExcelOutputMeta.font_name_code.length));
attrValidatorMap.put("headerFontUnderline", new IntLoadSaveValidator(ExcelOutputMeta.font_underline_code.length));
attrValidatorMap.put("headerFontOrientation", new IntLoadSaveValidator(ExcelOutputMeta.font_orientation_code.length));
attrValidatorMap.put("headerFontColor", new IntLoadSaveValidator(ExcelOutputMeta.font_color_code.length));
attrValidatorMap.put("headerBackGroundColor", new IntLoadSaveValidator(ExcelOutputMeta.font_color_code.length));
attrValidatorMap.put("headerAlignment", new IntLoadSaveValidator(ExcelOutputMeta.font_alignment_code.length));
attrValidatorMap.put("rowBackGroundColor", new IntLoadSaveValidator(ExcelOutputMeta.font_color_code.length));
attrValidatorMap.put("rowFontName", new IntLoadSaveValidator(ExcelOutputMeta.font_name_code.length));
attrValidatorMap.put("rowFontColor", new IntLoadSaveValidator(ExcelOutputMeta.font_color_code.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.IntLoadSaveValidator 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.IntLoadSaveValidator 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);
}
Aggregations