Search in sources :

Example 51 with FieldLoadSaveValidator

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

the class FieldSplitterMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("splitfield", "delimiter", "enclosure", "name", "id", "idrem", "type", "format", "group", "decimal", "currency", "length", "precision", "nullif", "ifnull", "trimtype");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("splitfield", "getSplitField");
    getterMap.put("delimiter", "getDelimiter");
    getterMap.put("enclosure", "getEnclosure");
    getterMap.put("name", "getFieldName");
    getterMap.put("id", "getFieldID");
    getterMap.put("idrem", "getFieldRemoveID");
    getterMap.put("type", "getFieldType");
    getterMap.put("format", "getFieldFormat");
    getterMap.put("group", "getFieldGroup");
    getterMap.put("decimal", "getFieldDecimal");
    getterMap.put("currency", "getFieldCurrency");
    getterMap.put("length", "getFieldLength");
    getterMap.put("precision", "getFieldPrecision");
    getterMap.put("nullif", "getFieldNullIf");
    getterMap.put("ifnull", "getFieldIfNull");
    getterMap.put("trimtype", "getFieldTrimType");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("splitfield", "setSplitField");
    setterMap.put("delimiter", "setDelimiter");
    setterMap.put("enclosure", "setEnclosure");
    setterMap.put("name", "setFieldName");
    setterMap.put("id", "setFieldID");
    setterMap.put("idrem", "setFieldRemoveID");
    setterMap.put("type", "setFieldType");
    setterMap.put("format", "setFieldFormat");
    setterMap.put("group", "setFieldGroup");
    setterMap.put("decimal", "setFieldDecimal");
    setterMap.put("currency", "setFieldCurrency");
    setterMap.put("length", "setFieldLength");
    setterMap.put("precision", "setFieldPrecision");
    setterMap.put("nullif", "setFieldNullIf");
    setterMap.put("ifnull", "setFieldIfNull");
    setterMap.put("trimtype", "setFieldTrimType");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorAttributeMap.put("name", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("id", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("idrem", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaFactory.getAllValueMetaNames().length), 5));
    fieldLoadSaveValidatorAttributeMap.put("format", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("group", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("decimal", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("currency", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("nullif", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("ifnull", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    fieldLoadSaveValidatorAttributeMap.put("trimtype", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaBase.getTrimTypeCodes().length), 5));
    LoadSaveTester loadSaveTester = new LoadSaveTester(FieldSplitterMeta.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) 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 52 with FieldLoadSaveValidator

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

the class FilesToResultMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("filename_field", "file_type");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("filename_field", "getFilenameField");
    getterMap.put("file_type", "getFileType");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("filename_field", "setFilenameField");
    setterMap.put("file_type", "setFileType");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorAttributeMap.put("file_type", new IntLoadSaveValidator(ResultFile.fileTypeCode.length));
    LoadSaveTester loadSaveTester = new LoadSaveTester(FilesToResultMeta.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) Test(org.junit.Test)

Example 53 with FieldLoadSaveValidator

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

the class FixedInputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("filename", "headerPresent", "lineWidth", "bufferSize", "lazyConversionActive", "lineFeedPresent", "runningInParallel", "fileType", "addResultFile", "encoding", "fieldDefinition");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldDefinition", new ArrayLoadSaveValidator<FixedFileInputField>(new FixedFileInputFieldLoadSaveValidator(), 5));
    attrValidatorMap.put("fileType", new IntLoadSaveValidator(FixedInputMeta.fileTypeDesc.length));
    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 : 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) Before(org.junit.Before)

Example 54 with FieldLoadSaveValidator

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

the class FormulaMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("formula");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("formula", "getFormula");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("formula", "setFormula");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    FieldLoadSaveValidator<FormulaMetaFunction[]> formulaMetaFunctionArrayLoadSaveValidator = new ArrayLoadSaveValidator<FormulaMetaFunction>(new FormulaMetaFunctionFieldLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("formula", formulaMetaFunctionArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(FormulaMeta.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) Test(org.junit.Test)

Example 55 with FieldLoadSaveValidator

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

the class FuzzyMatchMetaTest method setUp.

@Before
public void setUp() throws Exception {
    List<String> attributes = Arrays.asList("value", "valueName", "algorithm", "lookupfield", "mainstreamfield", "outputmatchfield", "outputvaluefield", "caseSensitive", "minimalValue", "maximalValue", "separator", "closervalue");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("value", "getValue");
            put("valueName", "getValueName");
            put("algorithm", "getAlgorithmType");
            put("lookupfield", "getLookupField");
            put("mainstreamfield", "getMainStreamField");
            put("outputmatchfield", "getOutputMatchField");
            put("outputvaluefield", "getOutputValueField");
            put("caseSensitive", "isCaseSensitive");
            put("minimalValue", "getMinimalValue");
            put("maximalValue", "getMaximalValue");
            put("separator", "getSeparator");
            put("closervalue", "isGetCloserValue");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("value", "setValue");
            put("valueName", "setValueName");
            put("algorithm", "setAlgorithmType");
            put("lookupfield", "setLookupField");
            put("mainstreamfield", "setMainStreamField");
            put("outputmatchfield", "setOutputMatchField");
            put("outputvaluefield", "setOutputValueField");
            put("caseSensitive", "setCaseSensitive");
            put("minimalValue", "setMinimalValue");
            put("maximalValue", "setMaximalValue");
            put("separator", "setSeparator");
            put("closervalue", "setGetCloserValue");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 3);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("value", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("algorithm", new AlgorithmLoadSaveValidator());
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    // typeValidatorMap.put( int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator( new IntLoadSaveValidator(), 3 ) );
    loadSaveTester = new LoadSaveTester(FuzzyMatchMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
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) Before(org.junit.Before)

Aggregations

FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)154 HashMap (java.util.HashMap)147 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)128 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)90 Before (org.junit.Before)89 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)72 ArrayList (java.util.ArrayList)59 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)47 Test (org.junit.Test)44 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)31 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)22 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)16 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)14 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)9 Random (java.util.Random)6 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 Repository (org.pentaho.di.repository.Repository)4 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)4