use of org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes in project pentaho-kettle by pentaho.
the class PDI_11319Test method testLoadXMLVersion5.
/**
* Test transformation created in Kettle 5 - should work w/ and w/o the fix
*/
@Test
public void testLoadXMLVersion5() throws Exception {
Node nullIfStep = getNullIfStep(xmlVersion5);
meta.loadXML(nullIfStep, null, (IMetaStore) null);
Assert.assertFalse("Set Empty String is true", meta.isSetEmptyStringAll());
boolean[] expected = { true, false, false };
ValueTypes[] actual = meta.getValueTypes();
Assert.assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; i++) {
Assert.assertEquals("Set empty string value type works incorrectly", expected[i], actual[i].isSetTypeEmptyString());
}
}
use of org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes in project pentaho-kettle by pentaho.
the class PDI_11319Test method testLoadXMLVersion4.
/**
* Test forward compatibility - transformation created in version 4 don't contain "set emtry" elements
*/
@Test
public void testLoadXMLVersion4() throws Exception {
Node nullIfStep = getNullIfStep(xmlVersion4);
meta.loadXML(nullIfStep, null, (IMetaStore) null);
Assert.assertFalse("Set Empty String is true", meta.isSetEmptyStringAll());
boolean[] expected = { false };
ValueTypes[] actual = meta.getValueTypes();
Assert.assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; i++) {
Assert.assertEquals("Set empty string value type works incorrectly", expected[i], actual[i].isSetTypeEmptyString());
}
}
use of org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes 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);
}
Aggregations