Search in sources :

Example 46 with ArrayLoadSaveValidator

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

the class DenormalizerMetaTest method setUpLoadSave.

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

        // CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
        {
        // put( "fieldName", "getFieldName" );
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        // CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
        {
        // put( "fieldName", "setFieldName" );
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("groupField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("denormaliserTargetField", new ArrayLoadSaveValidator<DenormaliserTargetField>(new DenormaliserTargetFieldLoadSaveValidator(), 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 47 with ArrayLoadSaveValidator

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

the class DimensionLookupMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    List<String> attributes = Arrays.asList("schemaName", "tableName", "update", "dateField", "dateFrom", "dateTo", "keyField", "keyRename", "autoIncrement", "versionField", "commitSize", "useBatchUpdate", "minYear", "maxYear", "techKeyCreation", "cacheSize", "usingStartDateAlternative", "startDateAlternative", "startDateFieldName", "preloadingCache", "keyStream", "keyLookup", "fieldStream", "fieldLookup", "fieldUpdate", "databaseMeta", "sequenceName");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("useBatchUpdate", "useBatchUpdate");
        }
    };
    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("keyStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyLookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldLookup", stringArrayLoadSaveValidator);
    // Note - have to use the non-zero int load/save validator here because if "update"
    // is false, code in DimensionLookupMeta replaces "ValueMetaInterface.TYPE_NONE" with
    // ValueMetaInterface.TYPE_STRING. This happens about once out of every 3 or so runs of
    // the test which made it a bit difficult to track down.
    // MB - 5/2016
    attrValidatorMap.put("fieldUpdate", new FieldUpdateIntArrayLoadSaveValidator(new NonZeroIntLoadSaveValidator(DimensionLookupMeta.typeDesc.length), 5));
    attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
    attrValidatorMap.put("startDateAlternative", new IntLoadSaveValidator(DimensionLookupMeta.getStartDateAlternativeCodes().length));
    attrValidatorMap.put("sequenceName", new SequenceNameLoadSaveValidator());
    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) NonZeroIntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator) IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) NonZeroIntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator) 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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Matchers.anyString(org.mockito.Matchers.anyString) DatabaseMetaLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 48 with ArrayLoadSaveValidator

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

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

the class GetFileNamesMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("filterfiletype", "doNotFailIfNoFile", "rownum", "isaddresult", "filefield", "rownum_field", "filename_Field", "wildcard_Field", "exclude_wildcard_Field", "dynamic_include_subfolders", "limit", "name", "filemask", "exclude_filemask", "file_required", "include_subfolders");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("filterfiletype", "getFileTypeFilter");
    getterMap.put("doNotFailIfNoFile", "isdoNotFailIfNoFile");
    getterMap.put("rownum", "includeRowNumber");
    getterMap.put("isaddresult", "isAddResultFile");
    getterMap.put("filefield", "isFileField");
    getterMap.put("rownum_field", "getRowNumberField");
    getterMap.put("filename_Field", "getDynamicFilenameField");
    getterMap.put("wildcard_Field", "getDynamicWildcardField");
    getterMap.put("exclude_wildcard_Field", "getDynamicExcludeWildcardField");
    getterMap.put("dynamic_include_subfolders", "isDynamicIncludeSubFolders");
    getterMap.put("limit", "getRowLimit");
    getterMap.put("name", "getFileName");
    getterMap.put("filemask", "getFileMask");
    getterMap.put("exclude_filemask", "getExludeFileMask");
    getterMap.put("file_required", "getFileRequired");
    getterMap.put("include_subfolders", "getIncludeSubFolders");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("filterfiletype", "setFilterFileType");
    setterMap.put("doNotFailIfNoFile", "setdoNotFailIfNoFile");
    setterMap.put("rownum", "setIncludeRowNumber");
    setterMap.put("isaddresult", "setAddResultFile");
    setterMap.put("filefield", "setFileField");
    setterMap.put("rownum_field", "setRowNumberField");
    setterMap.put("filename_Field", "setDynamicFilenameField");
    setterMap.put("wildcard_Field", "setDynamicWildcardField");
    setterMap.put("exclude_wildcard_Field", "setDynamicExcludeWildcardField");
    setterMap.put("dynamic_include_subfolders", "setDynamicIncludeSubFolders");
    setterMap.put("limit", "setRowLimit");
    setterMap.put("name", "setFileName");
    setterMap.put("filemask", "setFileMask");
    setterMap.put("exclude_filemask", "setExcludeFileMask");
    setterMap.put("file_required", "setFileRequired");
    setterMap.put("include_subfolders", "setIncludeSubFolders");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    // Arrays need to be consistent length
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    FieldLoadSaveValidator<String[]> fileRequiredArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new FileRequiredLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("filterfiletype", new FileTypeFilterLoadSaveValidator());
    fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("filemask", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("exclude_filemask", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("file_required", fileRequiredArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("include_subfolders", stringArrayLoadSaveValidator);
    LoadSaveTester<GetFileNamesMeta> loadSaveTester = new LoadSaveTester<>(GetFileNamesMeta.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) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 50 with ArrayLoadSaveValidator

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

the class TransExecutorMetaTest method setUp.

@Before
public void setUp() throws Exception {
    List<String> attributes = Arrays.asList("fileName", "transName", "directoryPath", "groupSize", "groupField", "groupTime", "executionTimeField", "executionFilesRetrievedField", "executionLogTextField", "executionLogChannelIdField", "executionResultField", "executionNrErrorsField", "executionLinesReadField", "executionLinesWrittenField", "executionLinesInputField", "executionLinesOutputField", "executionLinesRejectedField", "executionLinesUpdatedField", "executionLinesDeletedField", "executionExitStatusField", "outputRowsField", "outputRowsType", "outputRowsLength", "outputRowsPrecision");
    // executionResultTargetStepMeta -? (see for switch case meta)
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 1);
    // don't want the random value given by the default getTestObject...
    IntLoadSaveValidator intValidator = spy(new IntLoadSaveValidator());
    doReturn(ValueMetaInterface.TYPE_INTEGER).when(intValidator).getTestObject();
    FieldLoadSaveValidator<int[]> intArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(intValidator, 1);
    attrValidatorMap.put("outputRowsField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("outputRowsType", intArrayLoadSaveValidator);
    attrValidatorMap.put("outputRowsLength", intArrayLoadSaveValidator);
    attrValidatorMap.put("outputRowsPrecision", intArrayLoadSaveValidator);
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 1));
    loadSaveTester = new LoadSaveTester(TransExecutorMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) 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) Mockito.anyString(org.mockito.Mockito.anyString) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Aggregations

ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)73 HashMap (java.util.HashMap)72 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)72 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)69 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)67 Before (org.junit.Before)58 ArrayList (java.util.ArrayList)44 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)22 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)21 Test (org.junit.Test)15 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)15 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)13 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)10 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)5 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)3 YNLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator)3 Matchers.anyString (org.mockito.Matchers.anyString)2 Mockito.anyString (org.mockito.Mockito.anyString)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)2 Trans (org.pentaho.di.trans.Trans)2