use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator 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);
}
use of org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class GetFilesRowsCountMetaTest method setUp.
@Before
public void setUp() throws Exception {
List<String> attributes = Arrays.asList("fileName", "fileMask", "excludeFileMask", "includeFilesCount", "filesCountFieldName", "rowsCountFieldName", "RowSeparator_format", "RowSeparator", "filefield", "isaddresult", "outputFilenameField", "fileRequired", "includeSubFolders", "smartCount");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("fileName", "getFileName");
put("fileMask", "getFileMask");
put("excludeFileMask", "getExcludeFileMask");
put("includeFilesCount", "includeCountFiles");
put("filesCountFieldName", "getFilesCountFieldName");
put("rowsCountFieldName", "getRowsCountFieldName");
put("RowSeparator_format", "getRowSeparatorFormat");
put("RowSeparator", "getRowSeparator");
put("filefield", "isFileField");
put("isaddresult", "isAddResultFile");
put("outputFilenameField", "getOutputFilenameField");
put("fileRequired", "getFileRequired");
put("includeSubFolders", "getIncludeSubFolders");
put("smartCount", "isSmartCount");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("fileName", "setFileName");
put("fileMask", "setFileMask");
put("excludeFileMask", "setExcludeFileMask");
put("includeFilesCount", "setIncludeCountFiles");
put("filesCountFieldName", "setFilesCountFieldName");
put("rowsCountFieldName", "setRowsCountFieldName");
put("RowSeparator_format", "setRowSeparatorFormat");
put("RowSeparator", "setRowSeparator");
put("filefield", "setFileField");
put("isaddresult", "setAddResultFile");
put("outputFilenameField", "setOutputFilenameField");
put("fileRequired", "setFileRequired");
put("includeSubFolders", "setIncludeSubFolders");
put("smartCount", "setSmartCount");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
FieldLoadSaveValidator<String[]> ynArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new YNLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fileName", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileRequired", ynArrayLoadSaveValidator);
attrValidatorMap.put("includeSubFolders", ynArrayLoadSaveValidator);
attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(GetFilesRowsCountMeta.class, 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 UniqueRowsMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("count_rows", "count_field", "reject_duplicate_row", "error_description", "name", "case_insensitive");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("count_rows", "isCountRows");
getterMap.put("count_field", "getCountField");
getterMap.put("reject_duplicate_row", "isRejectDuplicateRow");
getterMap.put("error_description", "getErrorDescription");
getterMap.put("name", "getCompareFields");
getterMap.put("case_insensitive", "getCaseInsensitive");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("count_rows", "setCountRows");
setterMap.put("count_field", "setCountField");
setterMap.put("reject_duplicate_row", "setRejectDuplicateRow");
setterMap.put("error_description", "setErrorDescription");
setterMap.put("name", "setCompareFields");
setterMap.put("case_insensitive", "setCaseInsensitive");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
// Arrays need to be consistent length
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
FieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("case_insensitive", booleanArrayLoadSaveValidator);
LoadSaveTester loadSaveTester = new LoadSaveTester(UniqueRowsMeta.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 UpdateMetaTest method setUp.
@Before
public void setUp() throws KettleException {
KettleEnvironment.init();
PluginRegistry.init(false);
TransMeta transMeta = new TransMeta();
transMeta.setName("delete1");
Map<String, String> vars = new HashMap<String, String>();
vars.put("max.sz", "10");
transMeta.injectVariables(vars);
umi = new UpdateMeta();
ud = new UpdateData();
PluginRegistry plugReg = PluginRegistry.getInstance();
String deletePid = plugReg.getPluginId(StepPluginType.class, umi);
stepMeta = new StepMeta(deletePid, "delete", umi);
Trans trans = new Trans(transMeta);
transMeta.addStep(stepMeta);
mockHelper = new StepMockHelper<>("Update", UpdateMeta.class, UpdateData.class);
Mockito.when(mockHelper.logChannelInterfaceFactory.create(Mockito.any(), Mockito.any(LoggingObjectInterface.class))).thenReturn(mockHelper.logChannelInterface);
upd = new Update(stepMeta, ud, 1, transMeta, trans);
upd.copyVariablesFrom(transMeta);
List<String> attributes = Arrays.asList("schemaName", "tableName", "commitSize", "errorIgnored", "ignoreFlagField", "skipLookup", "useBatchUpdate", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "databaseMeta");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("schemaName", "getSchemaName");
put("tableName", "getTableName");
put("commitSize", "getCommitSizeVar");
put("errorIgnored", "isErrorIgnored");
put("ignoreFlagField", "getIgnoreFlagField");
put("skipLookup", "isSkipLookup");
put("useBatchUpdate", "useBatchUpdate");
put("keyStream", "getKeyStream");
put("keyLookup", "getKeyLookup");
put("keyCondition", "getKeyCondition");
put("keyStream2", "getKeyStream2");
put("updateLookup", "getUpdateLookup");
put("updateStream", "getUpdateStream");
put("databaseMeta", "getDatabaseMeta");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("schemaName", "setSchemaName");
put("tableName", "setTableName");
put("commitSize", "setCommitSize");
put("errorIgnored", "setErrorIgnored");
put("ignoreFlagField", "setIgnoreFlagField");
put("skipLookup", "setSkipLookup");
put("useBatchUpdate", "setUseBatchUpdate");
put("keyStream", "setKeyStream");
put("keyLookup", "setKeyLookup");
put("keyCondition", "setKeyCondition");
put("keyStream2", "setKeyStream2");
put("updateLookup", "setUpdateLookup");
put("updateStream", "setUpdateStream");
put("databaseMeta", "setDatabaseMeta");
}
};
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("keyCondition", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyStream2", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateLookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
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 WriteToLogMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("displayHeader", "limitRows", "limitRowsNumber", "logmessage", "loglevel", "fieldName");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("displayHeader", "isdisplayHeader");
put("limitRows", "isLimitRows");
put("limitRowsNumber", "getLimitRowsNumber");
put("logmessage", "getLogMessage");
put("loglevel", "getLogLevelString");
put("fieldName", "getFieldName");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("displayHeader", "setdisplayHeader");
put("limitRows", "setLimitRows");
put("limitRowsNumber", "setLimitRowsNumber");
put("logmessage", "setLogMessage");
put("loglevel", "setLogLevelString");
put("fieldName", "setFieldName");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
attrValidatorMap.put("loglevel", new LogLevelLoadSaveValidator());
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