Search in sources :

Example 36 with IntLoadSaveValidator

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

the class ExcelInputMetaTest method testSerialization.

@Test
public void testSerialization() throws KettleException {
    List<String> attributes = Arrays.asList("fileName", "fileMask", "excludeFileMask", "fileRequired", "includeSubFolders", "field", "sheetName", "startRow", "startColumn", "spreadSheetType", "fileField", "sheetField", "sheetRowNumberField", "rowNumberField", "shortFileFieldName", "extensionFieldName", "pathFieldName", "sizeFieldName", "hiddenFieldName", "lastModificationTimeFieldName", "uriNameFieldName", "rootUriNameFieldName");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("excludeFileMask", "getExludeFileMask");
            put("shortFileFieldName", "getShortFileNameField");
            put("extensionFieldName", "getExtensionField");
            put("pathFieldName", "getPathField");
            put("sizeFieldName", "getSizeField");
            put("hiddenFieldName", "isHiddenField");
            put("lastModificationTimeFieldName", "getLastModificationDateField");
            put("uriNameFieldName", "getUriField");
            put("rootUriNameFieldName", "getRootUriField");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("shortFileFieldName", "setShortFileNameField");
            put("extensionFieldName", "setExtensionField");
            put("pathFieldName", "setPathField");
            put("sizeFieldName", "setSizeField");
            put("hiddenFieldName", "setIsHiddenField");
            put("lastModificationTimeFieldName", "setLastModificationDateField");
            put("uriNameFieldName", "setUriField");
            put("rootUriNameFieldName", "setRootUriField");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fileName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("sheetName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
    attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fileRequired", stringArrayLoadSaveValidator);
    attrValidatorMap.put("includeSubFolders", stringArrayLoadSaveValidator);
    attrValidatorMap.put("field", new ArrayLoadSaveValidator<ExcelInputField>(new ExcelInputFieldLoadSaveValidator(), 5));
    attrValidatorMap.put("spreadSheetType", new SpreadSheetTypeFieldLoadSaveValidator());
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
    loadSaveTester = new LoadSaveTester(ExcelInputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
    loadSaveTester.testSerialization();
}
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) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 37 with IntLoadSaveValidator

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

the class DataGridMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("currency", "decimal", "group", "fieldName", "fieldType", "fieldFormat", "fieldLength", "fieldPrecision", "setEmptyString", "dataLines", "fieldNullIf");
    Map<String, String> getterMap = new HashMap<>();
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("setEmptyString", "setEmptyString");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 3);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("currency", stringArrayLoadSaveValidator);
    attrValidatorMap.put("decimal", stringArrayLoadSaveValidator);
    attrValidatorMap.put("group", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldType", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldFormat", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldLength", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(75), 3));
    attrValidatorMap.put("fieldPrecision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 3));
    attrValidatorMap.put("setEmptyString", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 3));
    attrValidatorMap.put("dataLines", new DataGridLinesLoadSaveValidator());
    attrValidatorMap.put("fieldNullIf", 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 : 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 38 with IntLoadSaveValidator

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

the class DBProcMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("procedure", "resultName", "resultType", "autoCommit", "argumentType", "argument", "argumentDirection", "database");
    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("argument", stringArrayLoadSaveValidator);
    attrValidatorMap.put("argumentDirection", stringArrayLoadSaveValidator);
    attrValidatorMap.put("argumentType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(7), 5));
    attrValidatorMap.put("database", new DatabaseMetaLoadSaveValidator());
    attrValidatorMap.put("resultType", new IntLoadSaveValidator(7));
    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) DatabaseMetaLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 39 with IntLoadSaveValidator

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

the class ConstantMetaTest method setUpLoadSave.

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

        {
            put("setEmptyString", "isSetEmptyString");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("setEmptyString", "setEmptyString");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    PrimitiveIntArrayLoadSaveValidator intArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5);
    PrimitiveBooleanArrayLoadSaveValidator booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 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", intArrayLoadSaveValidator);
    attrValidatorMap.put("fieldPrecision", intArrayLoadSaveValidator);
    attrValidatorMap.put("setEmptyString", booleanArrayLoadSaveValidator);
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester<ConstantMeta>(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) 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 40 with IntLoadSaveValidator

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

the class JobEntryMailLoadSaveTest method createAttributeValidatorsMap.

@Override
protected Map<String, FieldLoadSaveValidator<?>> createAttributeValidatorsMap() {
    Map<String, FieldLoadSaveValidator<?>> validators = new HashMap<String, FieldLoadSaveValidator<?>>();
    validators.put("fileType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ResultFile.fileTypeCode.length)));
    int entries = new Random().nextInt(20) + 1;
    validators.put("embeddedimages", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), entries));
    validators.put("contentids", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), entries));
    return validators;
}
Also used : IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) Random(java.util.Random) HashMap(java.util.HashMap) 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)

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