use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class GetRepositoryNamesMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("object_type", "rownum", "rownum_field", "directory", "name_mask", "exclude_name_mask", "include_subfolders");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("object_type", "getObjectTypeSelection");
getterMap.put("rownum", "isIncludeRowNumber");
getterMap.put("rownum_field", "getRowNumberField");
getterMap.put("name_mask", "getNameMask");
getterMap.put("exclude_name_mask", "getExcludeNameMask");
getterMap.put("include_subfolders", "getIncludeSubFolders");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("object_type", "setObjectTypeSelection");
setterMap.put("rownum", "setIncludeRowNumber");
setterMap.put("rownum_field", "setRowNumberField");
setterMap.put("exclude_name_mask", "setExcludeNameMask");
setterMap.put("include_subfolders", "setIncludeSubFolders");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
fieldLoadSaveValidatorTypeMap.put(String[].class.getCanonicalName(), new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
fieldLoadSaveValidatorTypeMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 50));
fieldLoadSaveValidatorTypeMap.put(ObjectTypeSelection.class.getCanonicalName(), new ObjectTypeSelectionLoadSaveValidator());
LoadSaveTester tester = new LoadSaveTester(GetRepositoryNamesMeta.class, attributes, getterMap, setterMap, new HashMap<String, FieldLoadSaveValidator<?>>(), fieldLoadSaveValidatorTypeMap);
tester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class IfNullMetaTest method setUp.
@Before
public void setUp() throws Exception {
List<String> attributes = Arrays.asList("fields", "valueTypes", "selectFields", "selectValuesType", "replaceAllByValue", "replaceAllMask", "setEmptyStringAll");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("fields", "getFields");
put("valueTypes", "getValueTypes");
put("selectFields", "isSelectFields");
put("selectValuesType", "isSelectValuesType");
put("replaceAllByValue", "getReplaceAllByValue");
put("replaceAllMask", "getReplaceAllMask");
put("setEmptyStringAll", "isSetEmptyStringAll");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("fields", "setFields");
put("valueTypes", "setValueTypes");
put("selectFields", "setSelectFields");
put("selectValuesType", "setSelectValuesType");
put("replaceAllByValue", "setReplaceAllByValue");
put("replaceAllMask", "setReplaceAllMask");
put("setEmptyStringAll", "setEmptyStringAll");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 3);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
attrValidatorMap.put("replaceValue", stringArrayLoadSaveValidator);
attrValidatorMap.put("typeName", stringArrayLoadSaveValidator);
attrValidatorMap.put("typereplaceValue", stringArrayLoadSaveValidator);
attrValidatorMap.put("typereplaceMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("replaceMask", stringArrayLoadSaveValidator);
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 3));
Fields field = new Fields();
field.setFieldName("fieldName");
field.setReplaceValue("replaceValue");
field.setReplaceMask("replaceMask");
field.setEmptyString(true);
typeValidatorMap.put(Fields[].class.getCanonicalName(), new ArrayLoadSaveValidator<Fields>(new FieldsLoadSaveValidator(field), 3));
ValueTypes type = new ValueTypes();
type.setTypeName("typeName");
type.setTypereplaceValue("typereplaceValue");
type.setTypereplaceMask("typereplaceMask");
type.setTypeEmptyString(true);
typeValidatorMap.put(ValueTypes[].class.getCanonicalName(), new ArrayLoadSaveValidator<ValueTypes>(new ValueTypesLoadSaveValidator(type), 3));
loadSaveTester = new LoadSaveTester(IfNullMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class GPLoadMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("localHosts", "localhostPort", "schemaName", "tableName", "errorTableName", "gploadPath", "controlFile", "dataFile", "logFile", "nullAs", "databaseMeta", "fieldTable", "fieldStream", "matchColumn", "updateColumn", "dateMask", "maxErrors", "loadMethod", "loadAction", "encoding", "eraseFiles", "encloseNumbers", "delimiter", "updateCondition");
Map<String, String> getterMap = new HashMap<>();
Map<String, String> setterMap = new HashMap<>();
for (String attribute : attributes) {
if (attribute.equals("eraseFiles")) {
getterMap.put("eraseFiles", "isEraseFiles");
} else {
getterMap.put(attribute, "get" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1));
}
if (attribute.equals("matchColumn")) {
setterMap.put("matchColumn", "setMatchColumns");
} else {
setterMap.put(attribute, "set" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1));
}
}
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<>();
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<>();
fieldLoadSaveValidatorAttributeMap.put("dateMask", new ArrayLoadSaveValidator<>(new DateMaskLoadSaveValidator(), 10));
fieldLoadSaveValidatorTypeMap.put(DatabaseMeta.class.getCanonicalName(), new DatabaseMetaFieldLoadSaveValidator());
fieldLoadSaveValidatorTypeMap.put(String[].class.getCanonicalName(), new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), 10));
fieldLoadSaveValidatorTypeMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 10));
LoadSaveTester loadSaveTester = new LoadSaveTester(GPLoadMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, fieldLoadSaveValidatorTypeMap);
loadSaveTester.testRepoRoundTrip();
loadSaveTester.testXmlRoundTrip();
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class SortRowsMetaTest method testRoundTrips.
/**
* Replaced previous testRep with load/save tester. Should cover http://jira.pentaho.com/browse/BACKLOG-377
* @throws KettleException
*/
@Test
public void testRoundTrips() throws KettleException {
List<String> attributes = Arrays.asList("Directory", "Prefix", "SortSize", "FreeMemoryLimit", "CompressFiles", "CompressFilesVariable", "OnlyPassingUniqueRows", "FieldName", "Ascending", "CaseSensitive", "CollatorEnabled", "CollatorStrength", "PreSortedField");
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
FieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
FieldLoadSaveValidator<int[]> intArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 25);
fieldLoadSaveValidatorAttributeMap.put("FieldName", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("Ascending", booleanArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("CaseSensitive", booleanArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("CollatorEnabled", booleanArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("CollatorStrength", intArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("PreSortedField", booleanArrayLoadSaveValidator);
LoadSaveTester<SortRowsMeta> loadSaveTester = new LoadSaveTester<>(SortRowsMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class ConstantMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("currency", "decimal", "group", "value", "fieldName", "fieldType", "fieldFormat", "fieldLength", "fieldPrecision", "setEmptyString");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("setEmptyString", "isSetEmptyString");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("setEmptyString", "setEmptyString");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
PrimitiveIntArrayLoadSaveValidator intArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5);
PrimitiveBooleanArrayLoadSaveValidator booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("currency", stringArrayLoadSaveValidator);
attrValidatorMap.put("decimal", stringArrayLoadSaveValidator);
attrValidatorMap.put("group", stringArrayLoadSaveValidator);
attrValidatorMap.put("value", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldType", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldFormat", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldLength", intArrayLoadSaveValidator);
attrValidatorMap.put("fieldPrecision", intArrayLoadSaveValidator);
attrValidatorMap.put("setEmptyString", booleanArrayLoadSaveValidator);
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester<ConstantMeta>(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this);
}
Aggregations