Search in sources :

Example 96 with LoadSaveTester

use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester 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 97 with LoadSaveTester

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

the class FieldsChangeSequenceMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("start", "increment", "resultfieldName", "name");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("start", "getStart");
    getterMap.put("increment", "getIncrement");
    getterMap.put("resultfieldName", "getResultFieldName");
    getterMap.put("name", "getFieldName");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("start", "setStart");
    setterMap.put("increment", "setIncrement");
    setterMap.put("resultfieldName", "setResultFieldName");
    setterMap.put("name", "setFieldName");
    LoadSaveTester loadSaveTester = new LoadSaveTester(FieldsChangeSequenceMeta.class, attributes, getterMap, setterMap);
    loadSaveTester.testSerialization();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) Test(org.junit.Test)

Example 98 with LoadSaveTester

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

the class FileExistsMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("filenamefield", "resultfieldname", "includefiletype", "filetypefieldname", "addresultfilenames");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("filenamefield", "getDynamicFilenameField");
    getterMap.put("resultfieldname", "getResultFieldName");
    getterMap.put("includefiletype", "includeFileType");
    getterMap.put("filetypefieldname", "getFileTypeFieldName");
    getterMap.put("addresultfilenames", "addResultFilenames");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("filenamefield", "setDynamicFilenameField");
    setterMap.put("resultfieldname", "setResultFieldName");
    setterMap.put("includefiletype", "setincludeFileType");
    setterMap.put("filetypefieldname", "setFileTypeFieldName");
    setterMap.put("addresultfilenames", "setaddResultFilenames");
    LoadSaveTester loadSaveTester = new LoadSaveTester(FileExistsMeta.class, attributes, getterMap, setterMap);
    loadSaveTester.testSerialization();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) Test(org.junit.Test)

Example 99 with LoadSaveTester

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

the class TextFileInputMetaLoadSaveTest method setUp.

@Before
public void setUp() throws Exception {
    List<String> commonAttributes = Arrays.asList("errorCountField", "errorFieldsField", "errorTextField", "length");
    List<String> xmlAttributes = Collections.emptyList();
    List<String> repoAttributes = Collections.emptyList();
    Map<String, String> getters = new HashMap<>();
    getters.put("header", "hasHeader");
    getters.put("footer", "hasFooter");
    getters.put("noEmptyLines", "noEmptyLines");
    getters.put("includeFilename", "includeFilename");
    getters.put("includeRowNumber", "includeRowNumber");
    getters.put("errorFilesExtension", "getErrorLineFilesExtension");
    getters.put("isaddresult", "isAddResultFile");
    getters.put("shortFileFieldName", "getShortFileNameField");
    getters.put("pathFieldName", "getPathField");
    getters.put("hiddenFieldName", "isHiddenField");
    getters.put("lastModificationTimeFieldName", "getLastModificationDateField");
    getters.put("uriNameFieldName", "getUriField");
    getters.put("rootUriNameFieldName", "getRootUriField");
    getters.put("extensionFieldName", "getExtensionField");
    getters.put("sizeFieldName", "getSizeField");
    Map<String, String> setters = new HashMap<>();
    setters.put("fileName", "setFileNameForTest");
    setters.put("errorFilesExtension", "setErrorLineFilesExtension");
    setters.put("isaddresult", "setAddResultFile");
    setters.put("shortFileFieldName", "setShortFileNameField");
    setters.put("pathFieldName", "setPathField");
    setters.put("hiddenFieldName", "setIsHiddenField");
    setters.put("lastModificationTimeFieldName", "setLastModificationDateField");
    setters.put("uriNameFieldName", "setUriField");
    setters.put("rootUriNameFieldName", "setRootUriField");
    setters.put("extensionFieldName", "setExtensionField");
    setters.put("sizeFieldName", "setSizeField");
    Map<String, FieldLoadSaveValidator<?>> attributeValidators = Collections.emptyMap();
    Map<String, FieldLoadSaveValidator<?>> typeValidators = new HashMap<>();
    typeValidators.put(TextFileFilter[].class.getCanonicalName(), new ArrayLoadSaveValidator<>(new TextFileFilterValidator()));
    typeValidators.put(BaseFileField[].class.getCanonicalName(), new ArrayLoadSaveValidator<>(new TextFileInputFieldValidator()));
    assertTrue(!commonAttributes.isEmpty() || !(xmlAttributes.isEmpty() || repoAttributes.isEmpty()));
    tester = new LoadSaveTester(TextFileInputMeta.class, commonAttributes, xmlAttributes, repoAttributes, getters, setters, attributeValidators, typeValidators);
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) Before(org.junit.Before)

Example 100 with LoadSaveTester

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

the class FilterRowsMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("condition", "send_true_to", "send_false_to");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("condition", new ConditionLoadSaveValidator());
    attrValidatorMap.put("trueStepName", new StringLoadSaveValidator());
    attrValidatorMap.put("falseStepname", new StringLoadSaveValidator());
    getterMap.put("send_true_to", "getTrueStepname");
    setterMap.put("send_true_to", "setTrueStepname");
    getterMap.put("send_false_to", "getFalseStepname");
    setterMap.put("send_false_to", "setFalseStepname");
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Also used : ConditionLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ConditionLoadSaveValidator) 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) Before(org.junit.Before)

Aggregations

LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)149 HashMap (java.util.HashMap)144 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)128 Before (org.junit.Before)86 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)81 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)67 Test (org.junit.Test)62 ArrayList (java.util.ArrayList)56 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)34 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)24 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)7 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)5 ObjectIdLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ObjectIdLoadSaveValidator)4 ObjectLocationSpecificationMethodLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ObjectLocationSpecificationMethodLoadSaveValidator)4 Matchers.anyString (org.mockito.Matchers.anyString)3 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)3 YNLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator)3