use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class DenormalizerMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("groupField", "keyField", "denormaliserTargetField");
Map<String, String> getterMap = new HashMap<String, String>() {
// CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
{
// put( "fieldName", "getFieldName" );
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
// CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
{
// put( "fieldName", "setFieldName" );
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("groupField", stringArrayLoadSaveValidator);
attrValidatorMap.put("denormaliserTargetField", new ArrayLoadSaveValidator<DenormaliserTargetField>(new DenormaliserTargetFieldLoadSaveValidator(), 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 DimensionLookupMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
List<String> attributes = Arrays.asList("schemaName", "tableName", "update", "dateField", "dateFrom", "dateTo", "keyField", "keyRename", "autoIncrement", "versionField", "commitSize", "useBatchUpdate", "minYear", "maxYear", "techKeyCreation", "cacheSize", "usingStartDateAlternative", "startDateAlternative", "startDateFieldName", "preloadingCache", "keyStream", "keyLookup", "fieldStream", "fieldLookup", "fieldUpdate", "databaseMeta", "sequenceName");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("useBatchUpdate", "useBatchUpdate");
}
};
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("keyStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyLookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldLookup", stringArrayLoadSaveValidator);
// Note - have to use the non-zero int load/save validator here because if "update"
// is false, code in DimensionLookupMeta replaces "ValueMetaInterface.TYPE_NONE" with
// ValueMetaInterface.TYPE_STRING. This happens about once out of every 3 or so runs of
// the test which made it a bit difficult to track down.
// MB - 5/2016
attrValidatorMap.put("fieldUpdate", new FieldUpdateIntArrayLoadSaveValidator(new NonZeroIntLoadSaveValidator(DimensionLookupMeta.typeDesc.length), 5));
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
attrValidatorMap.put("startDateAlternative", new IntLoadSaveValidator(DimensionLookupMeta.getStartDateAlternativeCodes().length));
attrValidatorMap.put("sequenceName", new SequenceNameLoadSaveValidator());
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 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.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class GetFileNamesMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("filterfiletype", "doNotFailIfNoFile", "rownum", "isaddresult", "filefield", "rownum_field", "filename_Field", "wildcard_Field", "exclude_wildcard_Field", "dynamic_include_subfolders", "limit", "name", "filemask", "exclude_filemask", "file_required", "include_subfolders");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("filterfiletype", "getFileTypeFilter");
getterMap.put("doNotFailIfNoFile", "isdoNotFailIfNoFile");
getterMap.put("rownum", "includeRowNumber");
getterMap.put("isaddresult", "isAddResultFile");
getterMap.put("filefield", "isFileField");
getterMap.put("rownum_field", "getRowNumberField");
getterMap.put("filename_Field", "getDynamicFilenameField");
getterMap.put("wildcard_Field", "getDynamicWildcardField");
getterMap.put("exclude_wildcard_Field", "getDynamicExcludeWildcardField");
getterMap.put("dynamic_include_subfolders", "isDynamicIncludeSubFolders");
getterMap.put("limit", "getRowLimit");
getterMap.put("name", "getFileName");
getterMap.put("filemask", "getFileMask");
getterMap.put("exclude_filemask", "getExludeFileMask");
getterMap.put("file_required", "getFileRequired");
getterMap.put("include_subfolders", "getIncludeSubFolders");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("filterfiletype", "setFilterFileType");
setterMap.put("doNotFailIfNoFile", "setdoNotFailIfNoFile");
setterMap.put("rownum", "setIncludeRowNumber");
setterMap.put("isaddresult", "setAddResultFile");
setterMap.put("filefield", "setFileField");
setterMap.put("rownum_field", "setRowNumberField");
setterMap.put("filename_Field", "setDynamicFilenameField");
setterMap.put("wildcard_Field", "setDynamicWildcardField");
setterMap.put("exclude_wildcard_Field", "setDynamicExcludeWildcardField");
setterMap.put("dynamic_include_subfolders", "setDynamicIncludeSubFolders");
setterMap.put("limit", "setRowLimit");
setterMap.put("name", "setFileName");
setterMap.put("filemask", "setFileMask");
setterMap.put("exclude_filemask", "setExcludeFileMask");
setterMap.put("file_required", "setFileRequired");
setterMap.put("include_subfolders", "setIncludeSubFolders");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
// Arrays need to be consistent length
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
FieldLoadSaveValidator<String[]> fileRequiredArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new FileRequiredLoadSaveValidator(), 25);
fieldLoadSaveValidatorAttributeMap.put("filterfiletype", new FileTypeFilterLoadSaveValidator());
fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("filemask", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("exclude_filemask", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("file_required", fileRequiredArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("include_subfolders", stringArrayLoadSaveValidator);
LoadSaveTester<GetFileNamesMeta> loadSaveTester = new LoadSaveTester<>(GetFileNamesMeta.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 TransExecutorMetaTest method setUp.
@Before
public void setUp() throws Exception {
List<String> attributes = Arrays.asList("fileName", "transName", "directoryPath", "groupSize", "groupField", "groupTime", "executionTimeField", "executionFilesRetrievedField", "executionLogTextField", "executionLogChannelIdField", "executionResultField", "executionNrErrorsField", "executionLinesReadField", "executionLinesWrittenField", "executionLinesInputField", "executionLinesOutputField", "executionLinesRejectedField", "executionLinesUpdatedField", "executionLinesDeletedField", "executionExitStatusField", "outputRowsField", "outputRowsType", "outputRowsLength", "outputRowsPrecision");
// executionResultTargetStepMeta -? (see for switch case meta)
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 1);
// don't want the random value given by the default getTestObject...
IntLoadSaveValidator intValidator = spy(new IntLoadSaveValidator());
doReturn(ValueMetaInterface.TYPE_INTEGER).when(intValidator).getTestObject();
FieldLoadSaveValidator<int[]> intArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(intValidator, 1);
attrValidatorMap.put("outputRowsField", stringArrayLoadSaveValidator);
attrValidatorMap.put("outputRowsType", intArrayLoadSaveValidator);
attrValidatorMap.put("outputRowsLength", intArrayLoadSaveValidator);
attrValidatorMap.put("outputRowsPrecision", intArrayLoadSaveValidator);
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 1));
loadSaveTester = new LoadSaveTester(TransExecutorMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Aggregations