Search in sources :

Example 1 with ValueTypes

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());
    }
}
Also used : Node(org.w3c.dom.Node) ValueTypes(org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes) Test(org.junit.Test)

Example 2 with ValueTypes

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());
    }
}
Also used : Node(org.w3c.dom.Node) ValueTypes(org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes) Test(org.junit.Test)

Example 3 with ValueTypes

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);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) ValueTypes(org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes) Fields(org.pentaho.di.trans.steps.ifnull.IfNullMeta.Fields) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Aggregations

ValueTypes (org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes)3 Test (org.junit.Test)2 Node (org.w3c.dom.Node)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Fields (org.pentaho.di.trans.steps.ifnull.IfNullMeta.Fields)1 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)1 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)1 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)1 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)1 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)1 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)1