Search in sources :

Example 16 with StringLoadSaveValidator

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

the class InsertUpdateMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    List<String> attributes = Arrays.asList("schemaName", "tableName", "databaseMeta", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "update", "commitSize", "updateBypassed");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("schemaName", "getSchemaName");
            put("tableName", "getTableName");
            put("databaseMeta", "getDatabaseMeta");
            put("keyStream", "getKeyStream");
            put("keyLookup", "getKeyLookup");
            put("keyCondition", "getKeyCondition");
            put("keyStream2", "getKeyStream2");
            put("updateLookup", "getUpdateLookup");
            put("updateStream", "getUpdateStream");
            put("update", "getUpdate");
            put("commitSize", "getCommitSizeVar");
            put("updateBypassed", "isUpdateBypassed");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("schemaName", "setSchemaName");
            put("tableName", "setTableName");
            put("databaseMeta", "setDatabaseMeta");
            put("keyStream", "setKeyStream");
            put("keyLookup", "setKeyLookup");
            put("keyCondition", "setKeyCondition");
            put("keyStream2", "setKeyStream2");
            put("updateLookup", "setUpdateLookup");
            put("updateStream", "setUpdateStream");
            put("update", "setUpdate");
            put("commitSize", "setCommitSize");
            put("updateBypassed", "setUpdateBypassed");
        }
    };
    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());
    attrValidatorMap.put("update", new ArrayLoadSaveValidator<Boolean>(new BooleanLoadSaveValidator(), 5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeValidatorMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 3));
    loadSaveTester = new LoadSaveTester(InsertUpdateMeta.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) DatabaseMetaLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 17 with StringLoadSaveValidator

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

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

the class StepsMetricsMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("stepName", "stepCopyNr", "stepRequired", "stepnamefield", "stepidfield", "steplinesinputfield", "steplinesoutputfield", "steplinesreadfield", "steplinesupdatedfield", "steplineswrittentfield", "steplineserrorsfield", "stepsecondsfield");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("stepName", "getStepName");
            put("stepCopyNr", "getStepCopyNr");
            put("stepRequired", "getStepRequired");
            put("stepnamefield", "getStepNameFieldName");
            put("stepidfield", "getStepIdFieldName");
            put("steplinesinputfield", "getStepLinesInputFieldName");
            put("steplinesoutputfield", "getStepLinesOutputFieldName");
            put("steplinesreadfield", "getStepLinesReadFieldName");
            put("steplinesupdatedfield", "getStepLinesUpdatedFieldName");
            put("steplineswrittentfield", "getStepLinesWrittenFieldName");
            put("steplineserrorsfield", "getStepLinesErrorsFieldName");
            put("stepsecondsfield", "getStepSecondsFieldName");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("stepName", "setStepName");
            put("stepCopyNr", "setStepCopyNr");
            put("stepRequired", "setStepRequired");
            put("stepnamefield", "setStepNameFieldName");
            put("stepidfield", "setStepIdFieldName");
            put("steplinesinputfield", "setStepLinesInputFieldName");
            put("steplinesoutputfield", "setStepLinesOutputFieldName");
            put("steplinesreadfield", "setStepLinesReadFieldName");
            put("steplinesupdatedfield", "setStepLinesUpdatedFieldName");
            put("steplineswrittentfield", "setStepLinesWrittenFieldName");
            put("steplineserrorsfield", "setStepLinesErrorsFieldName");
            put("stepsecondsfield", "setStepSecondsFieldName");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("stepName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("stepCopyNr", stringArrayLoadSaveValidator);
    attrValidatorMap.put("stepRequired", stringArrayLoadSaveValidator);
    // attrValidatorMap.put( "setEmptyString",
    // new PrimitiveBooleanArrayLoadSaveValidator( new BooleanLoadSaveValidator(), 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) 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)

Example 19 with StringLoadSaveValidator

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

the class StringCutMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldInStream", "fieldOutStream", "cutFrom", "cutTo");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fieldInStream", "getFieldInStream");
            put("fieldOutStream", "getFieldOutStream");
            put("cutFrom", "getCutFrom");
            put("cutTo", "getCutTo");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fieldInStream", "setFieldInStream");
            put("fieldOutStream", "setFieldOutStream");
            put("cutFrom", "setCutFrom");
            put("cutTo", "setCutTo");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldInStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldOutStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("cutFrom", stringArrayLoadSaveValidator);
    attrValidatorMap.put("cutTo", 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 : 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)

Example 20 with StringLoadSaveValidator

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

the class TextFileInputMetaInjectionTest method createGeneratorsMapping.

private static Map<TextFileInputMetaInjection.Entry, Generator<?>> createGeneratorsMapping() {
    Map<TextFileInputMetaInjection.Entry, Generator<?>> generators = new EnumMap<TextFileInputMetaInjection.Entry, Generator<?>>(TextFileInputMetaInjection.Entry.class);
    Generator<String> stringGenerator = new ValidatorAdapter<String>(new StringLoadSaveValidator());
    List<TextFileInputMetaInjection.Entry> stringEntries = Arrays.asList(FILE_TYPE, SEPARATOR, ENCLOSURE, ESCAPE_CHAR, COMPRESSION_TYPE, FILENAME_FIELD, ROW_NUMBER_FIELD, FILE_FORMAT, ENCODING, ACCEPT_FILE_STEP, ACCEPT_FILE_FIELD, FILE_SHORT_FILE_FIELDNAME, FILE_PATH_FIELDNAME, FILE_LAST_MODIFICATION_FIELDNAME, FILE_URI_FIELDNAME, FILE_EXTENSION_FIELDNAME, FILE_SIZE_FIELDNAME, FILE_ERROR_FIELD, FILE_ERROR_MESSAGE_FIELD, ERROR_COUNT_FIELD, ERROR_FIELDS_FIELD, ERROR_TEXT_FIELD, WARNING_FILES_TARGET_DIR, WARNING_FILES_EXTENTION, ERROR_FILES_TARGET_DIR, ERROR_FILES_EXTENTION, LINE_NR_FILES_TARGET_DIR, LINE_NR_FILES_EXTENTION);
    for (TextFileInputMetaInjection.Entry entry : stringEntries) {
        generators.put(entry, stringGenerator);
    }
    Generator<String> intGenerator = new ValidatorAdapter<Integer>(new IntLoadSaveValidator());
    List<TextFileInputMetaInjection.Entry> intEntries = Arrays.asList(NR_HEADER_LINES, NR_FOOTER_LINES, NR_WRAPS, NR_DOC_HEADER_LINES, NR_LINES_PER_PAGE, ROW_LIMIT);
    for (TextFileInputMetaInjection.Entry entry : intEntries) {
        generators.put(entry, intGenerator);
    }
    Generator<String> yesNoGenerator = new YesNoGenerator();
    List<TextFileInputMetaInjection.Entry> yesNoEntries = Arrays.asList(BREAK_IN_ENCLOSURE, HEADER_PRESENT, HAS_FOOTER, HAS_WRAPPED_LINES, HAS_PAGED_LAYOUT, NO_EMPTY_LINES, INCLUDE_FILENAME, INCLUDE_ROW_NUMBER, ROW_NUMBER_BY_FILE, DATE_FORMAT_LENIENT, ACCEPT_FILE_NAMES, PASS_THROUGH_FIELDS, ADD_FILES_TO_RESULT, FILE_HIDDEN_FIELDNAME, SKIP_BAD_FILES, IGNORE_ERRORS, ERROR_LINES_SKIPPED);
    for (TextFileInputMetaInjection.Entry entry : yesNoEntries) {
        generators.put(entry, yesNoGenerator);
    }
    generators.put(DATE_FORMAT_LOCALE, new Constant<String>("en"));
    return generators;
}
Also used : IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) EnumMap(java.util.EnumMap) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)

Aggregations

StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)91 HashMap (java.util.HashMap)89 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)89 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)80 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)68 Before (org.junit.Before)59 ArrayList (java.util.ArrayList)49 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)31 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)30 Test (org.junit.Test)26 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)21 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)15 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)8 Random (java.util.Random)6 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)4 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)4 YNLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator)3 Matchers.anyString (org.mockito.Matchers.anyString)2 Mockito.anyString (org.mockito.Mockito.anyString)2