Search in sources :

Example 61 with ArrayLoadSaveValidator

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

Example 62 with ArrayLoadSaveValidator

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

the class SetVariableMetaTest method setUpLoadSave.

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

        {
            put("fieldName", "getFieldName");
            put("variableName", "getVariableName");
            put("variableType", "getVariableType");
            put("defaultValue", "getDefaultValue");
            put("usingFormatting", "isUsingFormatting");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fieldName", "setFieldName");
            put("variableName", "setVariableName");
            put("variableType", "setVariableType");
            put("defaultValue", "setDefaultValue");
            put("usingFormatting", "setUsingFormatting");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("variableName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("defaultValue", stringArrayLoadSaveValidator);
    // 4 variable types
    attrValidatorMap.put("variableType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(4), 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 : PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) 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) 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 63 with ArrayLoadSaveValidator

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

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

the class ExecSQLMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("databaseMeta", "sql", "executedEachInputRow", "updateField", "insertField", "deleteField", "readField", "singleStatement", "replaceVariables", "quoteString", "params", "arguments");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("replaceVariables", "setVariableReplacementActive");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("arguments", 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)

Example 65 with ArrayLoadSaveValidator

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

the class StringOperationsMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("padLen", "padChar", "fieldInStream", "fieldOutStream", "trimType", "lowerUpper", "initCap", "maskXML", "digits", "removeSpecialCharacters", "paddingType");
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("padLen", stringArrayLoadSaveValidator);
    attrValidatorMap.put("padChar", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldInStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldOutStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("trimType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(4), 5));
    attrValidatorMap.put("lowerUpper", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(StringOperationsMeta.lowerUpperCode.length), 5));
    attrValidatorMap.put("initCap", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(StringOperationsMeta.initCapCode.length), 5));
    attrValidatorMap.put("maskXML", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(StringOperationsMeta.maskXMLCode.length), 5));
    attrValidatorMap.put("digits", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(StringOperationsMeta.digitsCode.length), 5));
    attrValidatorMap.put("removeSpecialCharacters", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(StringOperationsMeta.removeSpecialCharactersCode.length), 5));
    attrValidatorMap.put("paddingType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(StringOperationsMeta.paddingCode.length), 5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), new HashMap<String, String>(), new HashMap<String, String>(), 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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Aggregations

ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)73 HashMap (java.util.HashMap)72 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)72 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)69 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)67 Before (org.junit.Before)58 ArrayList (java.util.ArrayList)44 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)22 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)21 Test (org.junit.Test)15 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)15 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)13 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)10 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)5 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)3 YNLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator)3 Matchers.anyString (org.mockito.Matchers.anyString)2 Mockito.anyString (org.mockito.Mockito.anyString)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)2 Trans (org.pentaho.di.trans.Trans)2