Search in sources :

Example 11 with BooleanLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator in project pentaho-kettle by pentaho.

the class SynchronizeAfterMergeMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("schemaName", "tableName", "databaseMeta", "commitSize", "tableNameInField", "tablenameField", "operationOrderField", "useBatchUpdate", "performLookup", "OrderInsert", "OrderUpdate", "OrderDelete", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "update");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("tableNameInField", "istablenameInField");
            put("tablenameField", "gettablenameField");
            put("useBatchUpdate", "useBatchUpdate");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("tableNameInField", "settablenameInField");
            put("tablenameField", "settablenameField");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("keyStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyStream2", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyLookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyCondition", stringArrayLoadSaveValidator);
    attrValidatorMap.put("updateLookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("updateStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("update", new ArrayLoadSaveValidator<Boolean>(new BooleanLoadSaveValidator(), 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);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) ArrayList(java.util.ArrayList) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 12 with BooleanLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator in project pentaho-kettle by pentaho.

the class ReplaceStringMetaTest method testRoundTrips.

@Test
public void testRoundTrips() throws KettleException {
    List<String> attributes = Arrays.asList("in_stream_name", "out_stream_name", "use_regex", "replace_string", "replace_by_string", "set_empty_string", "replace_field_by_string", "whole_word", "case_sensitive", "is_unicode");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("in_stream_name", "getFieldInStream");
    getterMap.put("out_stream_name", "getFieldOutStream");
    getterMap.put("use_regex", "getUseRegEx");
    getterMap.put("replace_string", "getReplaceString");
    getterMap.put("replace_by_string", "getReplaceByString");
    getterMap.put("set_empty_string", "isSetEmptyString");
    getterMap.put("replace_field_by_string", "getFieldReplaceByString");
    getterMap.put("whole_word", "getWholeWord");
    getterMap.put("case_sensitive", "getCaseSensitive");
    getterMap.put("is_unicode", "isUnicode");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("in_stream_name", "setFieldInStream");
    setterMap.put("out_stream_name", "setFieldOutStream");
    setterMap.put("use_regex", "setUseRegEx");
    setterMap.put("replace_string", "setReplaceString");
    setterMap.put("replace_by_string", "setReplaceByString");
    setterMap.put("set_empty_string", "setEmptyString");
    setterMap.put("replace_field_by_string", "setFieldReplaceByString");
    setterMap.put("whole_word", "setWholeWord");
    setterMap.put("case_sensitive", "setCaseSensitive");
    setterMap.put("is_unicode", "setIsUnicode");
    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);
    fieldLoadSaveValidatorAttributeMap.put("in_stream_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("out_stream_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("use_regex", booleanArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("replace_string", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("replace_by_string", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("set_empty_string", booleanArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("replace_field_by_string", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("whole_word", booleanArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("case_sensitive", booleanArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("is_unicode", booleanArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(ReplaceStringMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
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) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Mockito.anyString(org.mockito.Mockito.anyString) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 13 with BooleanLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator 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();
}
Also used : PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) 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) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 14 with BooleanLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator 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)

Example 15 with BooleanLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator in project pentaho-kettle by pentaho.

the class LDAPOutputMetaTest method setUp.

@Before
public void setUp() throws Exception {
    List<String> attributes = Arrays.asList("updateLookup", "updateStream", "update", "useAuthentication", "Host", "userName", "password", "port", "dnFieldName", "failIfNotExist", "searchBase", "multiValuedSeparator", "operationType", "oldDnFieldName", "newDnFieldName", "deleteRDN");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("updateLookup", "getUpdateLookup");
            put("updateStream", "getUpdateStream");
            put("update", "getUpdate");
            put("useAuthentication", "getUseAuthentication");
            put("Host", "getHost");
            put("userName", "getUserName");
            put("password", "getPassword");
            put("port", "getPort");
            put("dnFieldName", "getDnField");
            put("failIfNotExist", "isFailIfNotExist");
            put("searchBase", "getSearchBaseDN");
            put("multiValuedSeparator", "getMultiValuedSeparator");
            put("operationType", "getOperationType");
            put("oldDnFieldName", "getOldDnFieldName");
            put("newDnFieldName", "getNewDnFieldName");
            put("deleteRDN", "isDeleteRDN");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("updateLookup", "setUpdateLookup");
            put("updateStream", "setUpdateStream");
            put("update", "setUpdate");
            put("useAuthentication", "setUseAuthentication");
            put("Host", "setHost");
            put("userName", "setUserName");
            put("password", "setPassword");
            put("port", "setPort");
            put("dnFieldName", "setDnField");
            put("failIfNotExist", "setFailIfNotExist");
            put("searchBase", "setSearchBaseDN");
            put("multiValuedSeparator", "setMultiValuedSeparator");
            put("operationType", "setOperationType");
            put("oldDnFieldName", "setOldDnFieldName");
            put("newDnFieldName", "setNewDnFieldName");
            put("deleteRDN", "setDeleteRDN");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 3);
    FieldLoadSaveValidator<Boolean[]> booleanArrayLoadSaveValidator = new ArrayLoadSaveValidator<Boolean>(new BooleanLoadSaveValidator(), 3);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("update", booleanArrayLoadSaveValidator);
    attrValidatorMap.put("updateLookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("updateStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("operationType", new IntLoadSaveValidator(5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(LDAPOutputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
    PluginRegistry.addPluginType(TwoWayPasswordEncoderPluginType.getInstance());
    PluginRegistry.init();
    String passwordEncoderPluginID = Const.NVL(EnvUtil.getSystemProperty(Const.KETTLE_PASSWORD_ENCODER_PLUGIN), "Kettle");
    Encr.init(passwordEncoderPluginID);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Aggregations

HashMap (java.util.HashMap)21 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)21 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)21 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)21 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)20 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)15 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)14 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 Before (org.junit.Before)10 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)7 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)6 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Mockito.anyString (org.mockito.Mockito.anyString)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 Trans (org.pentaho.di.trans.Trans)1 TransMeta (org.pentaho.di.trans.TransMeta)1