Search in sources :

Example 26 with IntLoadSaveValidator

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

the class SymmetricCryptoTransMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    KettleEnvironment.init();
    List<String> attributes = Arrays.asList("operation_type", "algorithm", "schema", "secretKeyField", "messageField", "resultfieldname", "secretKey", "secretKeyInField", "readKeyAsBinary", "outputResultAsBinary");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("operation_type", "getOperationType");
    getterMap.put("algorithm", "getAlgorithm");
    getterMap.put("schema", "getSchema");
    getterMap.put("secretKeyField", "getSecretKeyField");
    getterMap.put("messageField", "getMessageField");
    getterMap.put("resultfieldname", "getResultfieldname");
    getterMap.put("secretKey", "getSecretKey");
    getterMap.put("secretKeyInField", "isSecretKeyInField");
    getterMap.put("readKeyAsBinary", "isReadKeyAsBinary");
    getterMap.put("outputResultAsBinary", "isOutputResultAsBinary");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("operation_type", "setOperationType");
    setterMap.put("algorithm", "setAlgorithm");
    setterMap.put("schema", "setSchema");
    setterMap.put("secretKeyField", "setsecretKeyField");
    setterMap.put("messageField", "setMessageField");
    setterMap.put("resultfieldname", "setResultfieldname");
    setterMap.put("secretKey", "setSecretKey");
    setterMap.put("secretKeyInField", "setSecretKeyInField");
    setterMap.put("readKeyAsBinary", "setReadKeyAsBinary");
    setterMap.put("outputResultAsBinary", "setOutputResultAsBinary");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidator = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidator.put("operation_type", new IntLoadSaveValidator(SymmetricCryptoTransMeta.operationTypeCode.length));
    LoadSaveTester loadSaveTester = new LoadSaveTester(SymmetricCryptoTransMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidator, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
Also used : 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) Test(org.junit.Test)

Example 27 with IntLoadSaveValidator

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

the class TransExecutorMetaTest method setUp.

@Before
public void setUp() throws Exception {
    List<String> attributes = Arrays.asList("fileName", "transName", "directoryPath", "groupSize", "groupField", "groupTime", "executionTimeField", "executionFilesRetrievedField", "executionLogTextField", "executionLogChannelIdField", "executionResultField", "executionNrErrorsField", "executionLinesReadField", "executionLinesWrittenField", "executionLinesInputField", "executionLinesOutputField", "executionLinesRejectedField", "executionLinesUpdatedField", "executionLinesDeletedField", "executionExitStatusField", "outputRowsField", "outputRowsType", "outputRowsLength", "outputRowsPrecision");
    // executionResultTargetStepMeta -? (see for switch case meta)
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 1);
    // don't want the random value given by the default getTestObject...
    IntLoadSaveValidator intValidator = spy(new IntLoadSaveValidator());
    doReturn(ValueMetaInterface.TYPE_INTEGER).when(intValidator).getTestObject();
    FieldLoadSaveValidator<int[]> intArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(intValidator, 1);
    attrValidatorMap.put("outputRowsField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("outputRowsType", intArrayLoadSaveValidator);
    attrValidatorMap.put("outputRowsLength", intArrayLoadSaveValidator);
    attrValidatorMap.put("outputRowsPrecision", intArrayLoadSaveValidator);
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 1));
    loadSaveTester = new LoadSaveTester(TransExecutorMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
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) Mockito.anyString(org.mockito.Mockito.anyString) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 28 with IntLoadSaveValidator

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

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

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

the class RandomValueMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("name", "type");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("name", "getFieldName");
    getterMap.put("type", "getFieldType");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("name", "setFieldName");
    setterMap.put("type", "setFieldType");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorAttributeMap.put("name", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    fieldLoadSaveValidatorAttributeMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(RandomValueMeta.functions.length), 25));
    LoadSaveTester loadSaveTester = new LoadSaveTester(RandomValueMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
Also used : 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) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Aggregations

IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)46 HashMap (java.util.HashMap)45 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)45 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)32 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)31 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)27 Before (org.junit.Before)22 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)20 ArrayList (java.util.ArrayList)18 Test (org.junit.Test)12 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)7 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)6 Random (java.util.Random)5 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 EnumMap (java.util.EnumMap)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Mockito.anyString (org.mockito.Mockito.anyString)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 StepInjectionMetaEntry (org.pentaho.di.trans.step.StepInjectionMetaEntry)1