Search in sources :

Example 56 with FieldLoadSaveValidator

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

the class GetFilesRowsCountMetaTest method setUp.

@Before
public void setUp() throws Exception {
    List<String> attributes = Arrays.asList("fileName", "fileMask", "excludeFileMask", "includeFilesCount", "filesCountFieldName", "rowsCountFieldName", "RowSeparator_format", "RowSeparator", "filefield", "isaddresult", "outputFilenameField", "fileRequired", "includeSubFolders", "smartCount");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fileName", "getFileName");
            put("fileMask", "getFileMask");
            put("excludeFileMask", "getExcludeFileMask");
            put("includeFilesCount", "includeCountFiles");
            put("filesCountFieldName", "getFilesCountFieldName");
            put("rowsCountFieldName", "getRowsCountFieldName");
            put("RowSeparator_format", "getRowSeparatorFormat");
            put("RowSeparator", "getRowSeparator");
            put("filefield", "isFileField");
            put("isaddresult", "isAddResultFile");
            put("outputFilenameField", "getOutputFilenameField");
            put("fileRequired", "getFileRequired");
            put("includeSubFolders", "getIncludeSubFolders");
            put("smartCount", "isSmartCount");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fileName", "setFileName");
            put("fileMask", "setFileMask");
            put("excludeFileMask", "setExcludeFileMask");
            put("includeFilesCount", "setIncludeCountFiles");
            put("filesCountFieldName", "setFilesCountFieldName");
            put("rowsCountFieldName", "setRowsCountFieldName");
            put("RowSeparator_format", "setRowSeparatorFormat");
            put("RowSeparator", "setRowSeparator");
            put("filefield", "setFileField");
            put("isaddresult", "setAddResultFile");
            put("outputFilenameField", "setOutputFilenameField");
            put("fileRequired", "setFileRequired");
            put("includeSubFolders", "setIncludeSubFolders");
            put("smartCount", "setSmartCount");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<String[]> ynArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new YNLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fileName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fileRequired", ynArrayLoadSaveValidator);
    attrValidatorMap.put("includeSubFolders", ynArrayLoadSaveValidator);
    attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(GetFilesRowsCountMeta.class, 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) YNLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator) 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 57 with FieldLoadSaveValidator

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

the class UniqueRowsMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("count_rows", "count_field", "reject_duplicate_row", "error_description", "name", "case_insensitive");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("count_rows", "isCountRows");
    getterMap.put("count_field", "getCountField");
    getterMap.put("reject_duplicate_row", "isRejectDuplicateRow");
    getterMap.put("error_description", "getErrorDescription");
    getterMap.put("name", "getCompareFields");
    getterMap.put("case_insensitive", "getCaseInsensitive");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("count_rows", "setCountRows");
    setterMap.put("count_field", "setCountField");
    setterMap.put("reject_duplicate_row", "setRejectDuplicateRow");
    setterMap.put("error_description", "setErrorDescription");
    setterMap.put("name", "setCompareFields");
    setterMap.put("case_insensitive", "setCaseInsensitive");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    // Arrays need to be consistent length
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    FieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("case_insensitive", booleanArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(UniqueRowsMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
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) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 58 with FieldLoadSaveValidator

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

the class UnivariateStatsMetaTest method loadSaveRoundTripTest.

@Test
public void loadSaveRoundTripTest() throws KettleException {
    List<String> attributes = Arrays.asList("inputFieldMetaFunctions");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorTypeMap.put(UnivariateStatsMetaFunction[].class.getCanonicalName(), univariateFunctionArrayFieldLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(UnivariateStatsMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), new HashMap<String, FieldLoadSaveValidator<?>>(), fieldLoadSaveValidatorTypeMap);
    loadSaveTester.testSerialization();
}
Also used : 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 59 with FieldLoadSaveValidator

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

the class UpdateMetaTest method setUp.

@Before
public void setUp() throws KettleException {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    TransMeta transMeta = new TransMeta();
    transMeta.setName("delete1");
    Map<String, String> vars = new HashMap<String, String>();
    vars.put("max.sz", "10");
    transMeta.injectVariables(vars);
    umi = new UpdateMeta();
    ud = new UpdateData();
    PluginRegistry plugReg = PluginRegistry.getInstance();
    String deletePid = plugReg.getPluginId(StepPluginType.class, umi);
    stepMeta = new StepMeta(deletePid, "delete", umi);
    Trans trans = new Trans(transMeta);
    transMeta.addStep(stepMeta);
    mockHelper = new StepMockHelper<>("Update", UpdateMeta.class, UpdateData.class);
    Mockito.when(mockHelper.logChannelInterfaceFactory.create(Mockito.any(), Mockito.any(LoggingObjectInterface.class))).thenReturn(mockHelper.logChannelInterface);
    upd = new Update(stepMeta, ud, 1, transMeta, trans);
    upd.copyVariablesFrom(transMeta);
    List<String> attributes = Arrays.asList("schemaName", "tableName", "commitSize", "errorIgnored", "ignoreFlagField", "skipLookup", "useBatchUpdate", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "databaseMeta");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("schemaName", "getSchemaName");
            put("tableName", "getTableName");
            put("commitSize", "getCommitSizeVar");
            put("errorIgnored", "isErrorIgnored");
            put("ignoreFlagField", "getIgnoreFlagField");
            put("skipLookup", "isSkipLookup");
            put("useBatchUpdate", "useBatchUpdate");
            put("keyStream", "getKeyStream");
            put("keyLookup", "getKeyLookup");
            put("keyCondition", "getKeyCondition");
            put("keyStream2", "getKeyStream2");
            put("updateLookup", "getUpdateLookup");
            put("updateStream", "getUpdateStream");
            put("databaseMeta", "getDatabaseMeta");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("schemaName", "setSchemaName");
            put("tableName", "setTableName");
            put("commitSize", "setCommitSize");
            put("errorIgnored", "setErrorIgnored");
            put("ignoreFlagField", "setIgnoreFlagField");
            put("skipLookup", "setSkipLookup");
            put("useBatchUpdate", "setUseBatchUpdate");
            put("keyStream", "setKeyStream");
            put("keyLookup", "setKeyLookup");
            put("keyCondition", "setKeyCondition");
            put("keyStream2", "setKeyStream2");
            put("updateLookup", "setUpdateLookup");
            put("updateStream", "setUpdateStream");
            put("databaseMeta", "setDatabaseMeta");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("keyStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyLookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyCondition", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyStream2", stringArrayLoadSaveValidator);
    attrValidatorMap.put("updateLookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("updateStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
    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) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) DatabaseMetaLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator) StepMeta(org.pentaho.di.trans.step.StepMeta) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) Trans(org.pentaho.di.trans.Trans) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 60 with FieldLoadSaveValidator

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

the class WriteToLogMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("displayHeader", "limitRows", "limitRowsNumber", "logmessage", "loglevel", "fieldName");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("displayHeader", "isdisplayHeader");
            put("limitRows", "isLimitRows");
            put("limitRowsNumber", "getLimitRowsNumber");
            put("logmessage", "getLogMessage");
            put("loglevel", "getLogLevelString");
            put("fieldName", "getFieldName");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("displayHeader", "setdisplayHeader");
            put("limitRows", "setLimitRows");
            put("limitRowsNumber", "setLimitRowsNumber");
            put("logmessage", "setLogMessage");
            put("loglevel", "setLogLevelString");
            put("fieldName", "setFieldName");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("loglevel", new LogLevelLoadSaveValidator());
    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)

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