use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class MappingMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("transName", "fileName", "directoryPath", "allowingMultipleInputs", "allowingMultipleOutputs", "specificationMethod", "transObjectId", "inputMappings", "outputMappings", "mappingParameters");
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("specificationMethod", new ObjectLocationSpecificationMethodLoadSaveValidator());
attrValidatorMap.put("transObjectId", new ObjectIdLoadSaveValidator());
attrValidatorMap.put("inputMappings", new ListLoadSaveValidator<MappingIODefinition>(new MappingIODefinitionLoadSaveValidator(), 5));
attrValidatorMap.put("outputMappings", new ListLoadSaveValidator<MappingIODefinition>(new MappingIODefinitionLoadSaveValidator(), 5));
attrValidatorMap.put("mappingParameters", new MappingParametersLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new HashMap<String, String>(), new HashMap<String, String>(), attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class LoadSaveTester method testRepoRoundTrip.
public void testRepoRoundTrip() throws KettleException {
T metaToSave = createMeta();
Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters(repoAttributes, metaToSave);
T metaLoaded = createMeta();
Repository rep = new MemoryRepository();
metaToSave.saveRep(rep, null, null);
metaLoaded.loadRep(rep, null);
validateLoadedMeta(repoAttributes, validatorMap, metaToSave, metaLoaded);
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class DynamicSQLRowMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("sql", "SQLFieldName", "rowLimit", "outerJoin", "variableReplace", "databaseMeta");
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("databaseMeta", new DatabaseMetaLoadSaveValidator());
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.FieldLoadSaveValidator 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.FieldLoadSaveValidator 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);
}
Aggregations