Search in sources :

Example 46 with StringLoadSaveValidator

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

the class UniqueRowsByHashSetMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("store_values", "reject_duplicate_row", "error_description", "name");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("store_values", "getStoreValues");
    getterMap.put("reject_duplicate_row", "isRejectDuplicateRow");
    getterMap.put("error_description", "getErrorDescription");
    getterMap.put("name", "getCompareFields");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("store_values", "setStoreValues");
    setterMap.put("reject_duplicate_row", "setRejectDuplicateRow");
    setterMap.put("error_description", "setErrorDescription");
    setterMap.put("name", "setCompareFields");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    // Arrays need to be consistent length
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(UniqueRowsByHashSetMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
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) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 47 with StringLoadSaveValidator

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

the class RandomCCNumberGeneratorMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("cardNumberFieldName", "cardLengthFieldName", "cardTypeFieldName", "cctype", "cclen", "ccsize");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("cardNumberFieldName", "getCardNumberFieldName");
    getterMap.put("cardLengthFieldName", "getCardLengthFieldName");
    getterMap.put("cardTypeFieldName", "getCardTypeFieldName");
    getterMap.put("cctype", "getFieldCCType");
    getterMap.put("cclen", "getFieldCCLength");
    getterMap.put("ccsize", "getFieldCCSize");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("cardNumberFieldName", "setCardNumberFieldName");
    setterMap.put("cardLengthFieldName", "setCardLengthFieldName");
    setterMap.put("cardTypeFieldName", "setCardTypeFieldName");
    setterMap.put("cctype", "setFieldCCType");
    setterMap.put("cclen", "setFieldCCLength");
    setterMap.put("ccsize", "setFieldCCSize");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorAttributeMap.put("cctype", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    fieldLoadSaveValidatorAttributeMap.put("cclen", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    fieldLoadSaveValidatorAttributeMap.put("ccsize", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    LoadSaveTester loadSaveTester = new LoadSaveTester(RandomCCNumberGeneratorMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 48 with StringLoadSaveValidator

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

the class RegexEvalMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("script", "matcher", "resultfieldname", "usevar", "allowcapturegroups", "replacefields", "canoneq", "caseinsensitive", "comment", "dotall", "multiline", "unicode", "unix", "fieldName", "fieldFormat", "fieldGroup", "fieldDecimal", "fieldCurrency", "fieldNullIf", "fieldIfNull", "fieldTrimType", "fieldLength", "fieldPrecision", "fieldType");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("script", "getScript");
            put("matcher", "getMatcher");
            put("resultfieldname", "getResultFieldName");
            put("usevar", "isUseVariableInterpolationFlagSet");
            put("allowcapturegroups", "isAllowCaptureGroupsFlagSet");
            put("replacefields", "isReplacefields");
            put("canoneq", "isCanonicalEqualityFlagSet");
            put("caseinsensitive", "isCaseInsensitiveFlagSet");
            put("comment", "isCommentFlagSet");
            put("dotall", "isDotAllFlagSet");
            put("multiline", "isMultilineFlagSet");
            put("unicode", "isUnicodeFlagSet");
            put("unix", "isUnixLineEndingsFlagSet");
            put("fieldName", "getFieldName");
            put("fieldFormat", "getFieldFormat");
            put("fieldGroup", "getFieldGroup");
            put("fieldDecimal", "getFieldDecimal");
            put("fieldCurrency", "getFieldCurrency");
            put("fieldNullIf", "getFieldNullIf");
            put("fieldIfNull", "getFieldIfNull");
            put("fieldTrimType", "getFieldTrimType");
            put("fieldLength", "getFieldLength");
            put("fieldPrecision", "getFieldPrecision");
            put("fieldType", "getFieldType");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("script", "setScript");
            put("matcher", "setMatcher");
            put("resultfieldname", "setResultFieldName");
            put("usevar", "setUseVariableInterpolationFlag");
            put("allowcapturegroups", "setAllowCaptureGroupsFlag");
            put("replacefields", "setReplacefields");
            put("canoneq", "setCanonicalEqualityFlag");
            put("caseinsensitive", "setCaseInsensitiveFlag");
            put("comment", "setCommentFlag");
            put("dotall", "setDotAllFlag");
            put("multiline", "setMultilineFlag");
            put("unicode", "setUnicodeFlag");
            put("unix", "setUnixLineEndingsFlag");
            put("fieldName", "setFieldName");
            put("fieldFormat", "setFieldFormat");
            put("fieldGroup", "setFieldGroup");
            put("fieldDecimal", "setFieldDecimal");
            put("fieldCurrency", "setFieldCurrency");
            put("fieldNullIf", "setFieldNullIf");
            put("fieldIfNull", "setFieldIfNull");
            put("fieldTrimType", "setFieldTrimType");
            put("fieldLength", "setFieldLength");
            put("fieldPrecision", "setFieldPrecision");
            put("fieldType", "setFieldType");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldFormat", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldGroup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldDecimal", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldCurrency", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldNullIf", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldIfNull", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldTrimType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaBase.getTrimTypeCodes().length), 5));
    attrValidatorMap.put("fieldLength", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("fieldPrecision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 5));
    attrValidatorMap.put("fieldType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 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) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) 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) ArrayList(java.util.ArrayList) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 49 with StringLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator 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 50 with StringLoadSaveValidator

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

the class SetValueFieldMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldName", "replaceByFieldValue");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fieldName", "getFieldName");
            put("replaceByFieldValue", "getReplaceByFieldValue");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fieldName", "setFieldName");
            put("replaceByFieldValue", "setReplaceByFieldValue");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("replaceByFieldValue", stringArrayLoadSaveValidator);
    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) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Aggregations

StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)91 HashMap (java.util.HashMap)89 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)89 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)80 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)68 Before (org.junit.Before)59 ArrayList (java.util.ArrayList)49 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)31 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)30 Test (org.junit.Test)26 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)21 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)15 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)8 Random (java.util.Random)6 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)4 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)4 YNLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator)3 Matchers.anyString (org.mockito.Matchers.anyString)2 Mockito.anyString (org.mockito.Mockito.anyString)2