Search in sources :

Example 1 with IntLoadSaveValidator

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

the class GaInputStepMetaTest method testSerialization.

@Test
public void testSerialization() throws KettleException {
    List<String> attributes = Arrays.asList("OAuthServiceAccount", "GaAppName", "OAuthKeyFile", "GaProfileName", "GaProfileTableId", "GaCustomTableId", "UseCustomTableId", "StartDate", "EndDate", "Dimensions", "Metrics", "Filters", "Sort", "UseSegment", "UseCustomSegment", "CustomSegment", "SegmentId", "SegmentName", "SamplingLevel", "RowLimit", "FeedFieldType", "FeedField", "OutputField", "OutputType", "ConversionMask");
    Map<String, FieldLoadSaveValidator<?>> attributeMap = new HashMap<>();
    Map<String, FieldLoadSaveValidator<?>> typeMap = new HashMap<>();
    int maxValueCount = ValueMetaFactory.getAllValueMetaNames().length;
    attributeMap.put("FeedField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("FeedFieldType", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("OutputField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("OutputType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(maxValueCount), 25));
    attributeMap.put("ConversionMask", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    LoadSaveTester<GaInputStepMeta> tester = new LoadSaveTester<>(GaInputStepMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), attributeMap, typeMap);
    tester.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)

Example 2 with IntLoadSaveValidator

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

the class RowGeneratorMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("neverEnding", "intervalInMs", "rowTimeField", "lastTimeField", "rowLimit", "currency", "decimal", "group", "value", "fieldName", "fieldType", "fieldFormat", "fieldLength", "fieldPrecision");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("neverEnding", "isNeverEnding");
            put("intervalInMs", "getIntervalInMs");
            put("rowTimeField", "getRowTimeField");
            put("lastTimeField", "getLastTimeField");
            put("rowLimit", "getRowLimit");
            put("currency", "getCurrency");
            put("decimal", "getDecimal");
            put("group", "getGroup");
            put("value", "getValue");
            put("fieldName", "getFieldName");
            put("fieldType", "getFieldType");
            put("fieldFormat", "getFieldFormat");
            put("fieldLength", "getFieldLength");
            put("fieldPrecision", "getFieldPrecision");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("neverEnding", "setNeverEnding");
            put("intervalInMs", "setIntervalInMs");
            put("rowTimeField", "setRowTimeField");
            put("lastTimeField", "setLastTimeField");
            put("rowLimit", "setRowLimit");
            put("currency", "setCurrency");
            put("decimal", "setDecimal");
            put("group", "setGroup");
            put("value", "setValue");
            put("fieldName", "setFieldName");
            put("fieldType", "setFieldType");
            put("fieldFormat", "setFieldFormat");
            put("fieldLength", "setFieldLength");
            put("fieldPrecision", "setFieldPrecision");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("currency", stringArrayLoadSaveValidator);
    attrValidatorMap.put("decimal", stringArrayLoadSaveValidator);
    attrValidatorMap.put("group", stringArrayLoadSaveValidator);
    attrValidatorMap.put("value", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldType", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldFormat", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldLength", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("fieldPrecision", 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 3 with IntLoadSaveValidator

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

the class RowsFromResultMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldname", "type", "length", "precision");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldname", stringArrayLoadSaveValidator);
    attrValidatorMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(7), 5));
    attrValidatorMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("precision", 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 : 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 4 with IntLoadSaveValidator

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

the class ScriptMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldname", "rename", "type", "length", "precision", "replace", "jsScripts");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fieldname", "getFieldname");
            put("rename", "getRename");
            put("type", "getType");
            put("length", "getLength");
            put("precision", "getPrecision");
            put("replace", "getReplace");
            put("jsScripts", "getJSScripts");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fieldname", "setFieldname");
            put("rename", "setRename");
            put("type", "setType");
            put("length", "setLength");
            put("precision", "setPrecision");
            put("replace", "setReplace");
            put("jsScripts", "setJSScripts");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<ScriptValuesScript[]> svsArrayLoadSaveValidator = new ArrayLoadSaveValidator<ScriptValuesScript>(new ScriptValuesScriptLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldname", stringArrayLoadSaveValidator);
    attrValidatorMap.put("rename", stringArrayLoadSaveValidator);
    attrValidatorMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 5));
    attrValidatorMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(6), 5));
    attrValidatorMap.put("replace", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5));
    attrValidatorMap.put("jsScripts", svsArrayLoadSaveValidator);
    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) 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) ArrayList(java.util.ArrayList) 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) Before(org.junit.Before)

Example 5 with IntLoadSaveValidator

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

the class ScriptValuesMetaModTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldname", "rename", "type", "length", "precision", "replace", "jsScripts", "compatible", "optimizationLevel");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fieldname", "getFieldname");
            put("rename", "getRename");
            put("type", "getType");
            put("length", "getLength");
            put("precision", "getPrecision");
            put("replace", "getReplace");
            put("compatible", "isCompatible");
            put("optimizationLevel", "getOptimizationLevel");
            put("jsScripts", "getJSScripts");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fieldname", "setFieldname");
            put("rename", "setRename");
            put("type", "setType");
            put("length", "setLength");
            put("precision", "setPrecision");
            put("replace", "setReplace");
            put("compatible", "setCompatible");
            put("optimizationLevel", "setOptimizationLevel");
            put("jsScripts", "setJSScripts");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<ScriptValuesScript[]> svsArrayLoadSaveValidator = new ArrayLoadSaveValidator<ScriptValuesScript>(new ScriptValuesScriptLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldname", stringArrayLoadSaveValidator);
    attrValidatorMap.put("rename", stringArrayLoadSaveValidator);
    attrValidatorMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 5));
    attrValidatorMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(6), 5));
    attrValidatorMap.put("replace", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5));
    attrValidatorMap.put("jsScripts", svsArrayLoadSaveValidator);
    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) 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) ArrayList(java.util.ArrayList) 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) Before(org.junit.Before)

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