Search in sources :

Example 11 with PrimitiveBooleanArrayLoadSaveValidator

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

the class GetRepositoryNamesMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("object_type", "rownum", "rownum_field", "directory", "name_mask", "exclude_name_mask", "include_subfolders");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("object_type", "getObjectTypeSelection");
    getterMap.put("rownum", "isIncludeRowNumber");
    getterMap.put("rownum_field", "getRowNumberField");
    getterMap.put("name_mask", "getNameMask");
    getterMap.put("exclude_name_mask", "getExcludeNameMask");
    getterMap.put("include_subfolders", "getIncludeSubFolders");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("object_type", "setObjectTypeSelection");
    setterMap.put("rownum", "setIncludeRowNumber");
    setterMap.put("rownum_field", "setRowNumberField");
    setterMap.put("exclude_name_mask", "setExcludeNameMask");
    setterMap.put("include_subfolders", "setIncludeSubFolders");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorTypeMap.put(String[].class.getCanonicalName(), new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    fieldLoadSaveValidatorTypeMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 50));
    fieldLoadSaveValidatorTypeMap.put(ObjectTypeSelection.class.getCanonicalName(), new ObjectTypeSelectionLoadSaveValidator());
    LoadSaveTester tester = new LoadSaveTester(GetRepositoryNamesMeta.class, attributes, getterMap, setterMap, new HashMap<String, FieldLoadSaveValidator<?>>(), fieldLoadSaveValidatorTypeMap);
    tester.testSerialization();
}
Also used : 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) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 12 with PrimitiveBooleanArrayLoadSaveValidator

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

the class IfNullMetaTest method setUp.

@Before
public void setUp() throws Exception {
    List<String> attributes = Arrays.asList("fields", "valueTypes", "selectFields", "selectValuesType", "replaceAllByValue", "replaceAllMask", "setEmptyStringAll");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fields", "getFields");
            put("valueTypes", "getValueTypes");
            put("selectFields", "isSelectFields");
            put("selectValuesType", "isSelectValuesType");
            put("replaceAllByValue", "getReplaceAllByValue");
            put("replaceAllMask", "getReplaceAllMask");
            put("setEmptyStringAll", "isSetEmptyStringAll");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fields", "setFields");
            put("valueTypes", "setValueTypes");
            put("selectFields", "setSelectFields");
            put("selectValuesType", "setSelectValuesType");
            put("replaceAllByValue", "setReplaceAllByValue");
            put("replaceAllMask", "setReplaceAllMask");
            put("setEmptyStringAll", "setEmptyStringAll");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 3);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("replaceValue", stringArrayLoadSaveValidator);
    attrValidatorMap.put("typeName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("typereplaceValue", stringArrayLoadSaveValidator);
    attrValidatorMap.put("typereplaceMask", stringArrayLoadSaveValidator);
    attrValidatorMap.put("replaceMask", stringArrayLoadSaveValidator);
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeValidatorMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 3));
    Fields field = new Fields();
    field.setFieldName("fieldName");
    field.setReplaceValue("replaceValue");
    field.setReplaceMask("replaceMask");
    field.setEmptyString(true);
    typeValidatorMap.put(Fields[].class.getCanonicalName(), new ArrayLoadSaveValidator<Fields>(new FieldsLoadSaveValidator(field), 3));
    ValueTypes type = new ValueTypes();
    type.setTypeName("typeName");
    type.setTypereplaceValue("typereplaceValue");
    type.setTypereplaceMask("typereplaceMask");
    type.setTypeEmptyString(true);
    typeValidatorMap.put(ValueTypes[].class.getCanonicalName(), new ArrayLoadSaveValidator<ValueTypes>(new ValueTypesLoadSaveValidator(type), 3));
    loadSaveTester = new LoadSaveTester(IfNullMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) 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) ValueTypes(org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes) Fields(org.pentaho.di.trans.steps.ifnull.IfNullMeta.Fields) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 13 with PrimitiveBooleanArrayLoadSaveValidator

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

the class GPLoadMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("localHosts", "localhostPort", "schemaName", "tableName", "errorTableName", "gploadPath", "controlFile", "dataFile", "logFile", "nullAs", "databaseMeta", "fieldTable", "fieldStream", "matchColumn", "updateColumn", "dateMask", "maxErrors", "loadMethod", "loadAction", "encoding", "eraseFiles", "encloseNumbers", "delimiter", "updateCondition");
    Map<String, String> getterMap = new HashMap<>();
    Map<String, String> setterMap = new HashMap<>();
    for (String attribute : attributes) {
        if (attribute.equals("eraseFiles")) {
            getterMap.put("eraseFiles", "isEraseFiles");
        } else {
            getterMap.put(attribute, "get" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1));
        }
        if (attribute.equals("matchColumn")) {
            setterMap.put("matchColumn", "setMatchColumns");
        } else {
            setterMap.put(attribute, "set" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1));
        }
    }
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<>();
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<>();
    fieldLoadSaveValidatorAttributeMap.put("dateMask", new ArrayLoadSaveValidator<>(new DateMaskLoadSaveValidator(), 10));
    fieldLoadSaveValidatorTypeMap.put(DatabaseMeta.class.getCanonicalName(), new DatabaseMetaFieldLoadSaveValidator());
    fieldLoadSaveValidatorTypeMap.put(String[].class.getCanonicalName(), new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), 10));
    fieldLoadSaveValidatorTypeMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 10));
    LoadSaveTester loadSaveTester = new LoadSaveTester(GPLoadMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, fieldLoadSaveValidatorTypeMap);
    loadSaveTester.testRepoRoundTrip();
    loadSaveTester.testXmlRoundTrip();
}
Also used : 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) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 14 with PrimitiveBooleanArrayLoadSaveValidator

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

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

Aggregations

HashMap (java.util.HashMap)16 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)16 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)16 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)16 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)16 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)15 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)13 Before (org.junit.Before)9 Test (org.junit.Test)7 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)7 ArrayList (java.util.ArrayList)6 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)6 Mockito.anyString (org.mockito.Mockito.anyString)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 Trans (org.pentaho.di.trans.Trans)1 TransMeta (org.pentaho.di.trans.TransMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 Fields (org.pentaho.di.trans.steps.ifnull.IfNullMeta.Fields)1 ValueTypes (org.pentaho.di.trans.steps.ifnull.IfNullMeta.ValueTypes)1