Search in sources :

Example 36 with StringLoadSaveValidator

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

the class CsvInputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("BufferSize", "Delimiter", "Enclosure", "Encoding", "Filename", "FilenameField", "InputFields", "RowNumField", "AddResultFile", "HeaderPresent", "IncludingFilename", "LazyConversionActive", "NewlinePossibleInFields", "RunningInParallel");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("hasHeader", "hasHeader");
            put("includeFilename", "includeFilename");
            put("includeRowNumber", "includeRowNumber");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("includeFilename", "includeFilename");
            put("includeRowNumber", "includeRowNumber");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("InputFields", new ArrayLoadSaveValidator<TextFileInputField>(new TextFileInputFieldValidator(), 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 : TextFileInputFieldValidator(org.pentaho.di.trans.steps.loadsave.validator.TextFileInputFieldValidator) 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) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField) ArrayList(java.util.ArrayList) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 37 with StringLoadSaveValidator

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

the class JsonInputMetaLoadSaveTest method testLoadSave.

@Test
public void testLoadSave() throws KettleException {
    List<String> attributes = Arrays.asList("includeFilename", "filenameField", "includeRowNumber", "addResultFile", "ReadUrl", "removeSourceField", "IgnoreEmptyFile", "doNotFailIfNoFile", "ignoreMissingPath", "defaultPathLeafToNull", "rowNumberField", "FileName", "FileMask", "ExcludeFileMask", "FileRequired", "IncludeSubFolders", "InputFields", "rowLimit", "inFields", "isAFile", "FieldValue", "ShortFileNameField", "PathField", "HiddenField", "LastModificationDateField", "UriField", "UriField", "ExtensionField", "SizeField");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    getterMap.put("includeFilename", "includeFilename");
    getterMap.put("includeRowNumber", "includeRowNumber");
    getterMap.put("addResultFile", "addResultFile");
    setterMap.put("HiddenField", "setIsHiddenField");
    Map<String, FieldLoadSaveValidator<?>> attributesMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    FieldLoadSaveValidator<?> fileStringArrayValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), FILE_COUNT);
    attributesMap.put("FileName", fileStringArrayValidator);
    attributesMap.put("FileMask", fileStringArrayValidator);
    attributesMap.put("ExcludeFileMask", fileStringArrayValidator);
    attributesMap.put("FileRequired", fileStringArrayValidator);
    attributesMap.put("IncludeSubFolders", fileStringArrayValidator);
    Map<String, FieldLoadSaveValidator<?>> typeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeMap.put(JsonInputField.class.getCanonicalName(), new ArrayLoadSaveValidator<JsonInputField>(new JsonInputFieldValidator()));
    typeMap.put(JsonInputField[].class.getCanonicalName(), new ArrayLoadSaveValidator<JsonInputField>(new JsonInputFieldValidator()));
    LoadSaveTester tester = new LoadSaveTester(JsonInputMeta.class, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attributesMap, typeMap, this);
    tester.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 38 with StringLoadSaveValidator

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

the class AccessInputMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("includeFilename", "filenameField", "includeTablename", "dynamicFilenameField", "tablenameField", "includeRowNumber", "addResultFile", "fileField", "rowNumberField", "resetRowNumber", "tableName", "fileName", "fileMask", "excludeFileMask", "fileRequired", "includeSubFolders", "inputFields", "rowLimit", "shortFileNameField", "pathField", "hiddenField", "lastModificationDateField", "uriField", "rootUriField", "extensionField", "sizeField");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    FieldLoadSaveValidator<?> stringArrayValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50);
    FieldLoadSaveValidator<?> fileRequiredArrayValidator = new ArrayLoadSaveValidator<String>(new FileRequiredLoadSaveValidator(), 50);
    FieldLoadSaveValidator<?> inputFieldArrayValidator = new ArrayLoadSaveValidator<AccessInputField>(new AccessInputFieldLoadSaveValidator(), 100);
    Map<String, FieldLoadSaveValidator<?>> typeValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
    Map<String, FieldLoadSaveValidator<?>> fieldValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldValidators.put("fileName", stringArrayValidator);
    fieldValidators.put("fileMask", stringArrayValidator);
    fieldValidators.put("excludeFileMask", stringArrayValidator);
    fieldValidators.put("fileRequired", fileRequiredArrayValidator);
    fieldValidators.put("includeSubFolders", stringArrayValidator);
    fieldValidators.put("inputFields", inputFieldArrayValidator);
    LoadSaveTester<AccessInputMeta> loadSaveTester = new LoadSaveTester<AccessInputMeta>(AccessInputMeta.class, attributes, getterMap, setterMap, fieldValidators, typeValidators);
    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 39 with StringLoadSaveValidator

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

the class SalesforceDeleteMetaTest method testLoadSave.

@Test
public void testLoadSave() throws KettleException {
    List<String> attributes = new ArrayList<String>();
    attributes.addAll(SalesforceMetaTest.getDefaultAttributes());
    attributes.addAll(Arrays.asList("deleteField", "batchSize", "rollbackAllChangesOnError"));
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidators.put("updateLookup", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    fieldLoadSaveValidators.put("updateStream", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    fieldLoadSaveValidators.put("useExternalId", new ArrayLoadSaveValidator<Boolean>(new BooleanLoadSaveValidator(), 50));
    LoadSaveTester loadSaveTester = new LoadSaveTester(SalesforceDeleteMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidators, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testRepoRoundTrip();
    loadSaveTester.testXmlRoundTrip();
}
Also used : 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) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) SalesforceMetaTest(org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest) Test(org.junit.Test)

Example 40 with StringLoadSaveValidator

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

the class SalesforceUpdateMetaTest method testSalesforceUpdateMeta.

@Test
public void testSalesforceUpdateMeta() throws KettleException {
    List<String> attributes = new ArrayList<String>();
    attributes.addAll(SalesforceMetaTest.getDefaultAttributes());
    attributes.addAll(Arrays.asList("batchSize", "updateLookup", "updateStream", "useExternalId", "rollbackAllChangesOnError"));
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidators.put("updateLookup", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    fieldLoadSaveValidators.put("updateStream", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    fieldLoadSaveValidators.put("useExternalId", new ArrayLoadSaveValidator<Boolean>(new BooleanLoadSaveValidator(), 50));
    LoadSaveTester loadSaveTester = new LoadSaveTester(SalesforceUpdateMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidators, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testRepoRoundTrip();
    loadSaveTester.testXmlRoundTrip();
}
Also used : 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) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) SalesforceMetaTest(org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest) Test(org.junit.Test)

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