Search in sources :

Example 86 with StringLoadSaveValidator

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

the class GetSubFoldersMetaTest method loadSaveTest.

@Test
public void loadSaveTest() throws KettleException {
    List<String> attributes = Arrays.asList("rownum", "foldername_dynamic", "rownum_field", "foldername_field", "limit", "name", "file_required");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("rownum", "includeRowNumber");
    getterMap.put("foldername_dynamic", "isFoldernameDynamic");
    getterMap.put("foldername_field", "getDynamicFoldernameField");
    getterMap.put("rownum_field", "getRowNumberField");
    getterMap.put("limit", "getRowLimit");
    getterMap.put("name", "getFolderName");
    getterMap.put("file_required", "getFolderRequired");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("rownum", "setIncludeRowNumber");
    setterMap.put("foldername_dynamic", "setFolderField");
    setterMap.put("foldername_field", "setDynamicFoldernameField");
    setterMap.put("rownum_field", "setRowNumberField");
    setterMap.put("limit", "setRowLimit");
    setterMap.put("name", "setFolderName");
    setterMap.put("file_required", "setFolderRequired");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorAttributeMap.put("file_required", new ArrayLoadSaveValidator<String>(new FileRequiredFieldLoadSaveValidator(), 50));
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorTypeMap.put(String[].class.getCanonicalName(), new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    LoadSaveTester tester = new LoadSaveTester(GetSubFoldersMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, 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) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 87 with StringLoadSaveValidator

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

Example 88 with StringLoadSaveValidator

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

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

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

the class HTTPMetaLoadSaveTest method testLoadSaveRoundTrip.

@Before
public void testLoadSaveRoundTrip() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("url", "urlInField", "urlField", "encoding", "httpLogin", "httpPassword", "proxyHost", "proxyPort", "socketTimeout", "connectionTimeout", "closeIdleConnectionsTime", "argumentField", "argumentParameter", "headerField", "headerParameter", "fieldName", "resultCodeFieldName", "responseTimeFieldName", "responseHeaderFieldName");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    // Arrays need to be consistent length
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("argumentField", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("argumentParameter", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("headerField", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("headerParameter", stringArrayLoadSaveValidator);
    loadSaveTester = new LoadSaveTester(HTTPMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
}
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) Before(org.junit.Before)

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