Search in sources :

Example 6 with LoadSaveTester

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

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

the class MetaInjectMetaLoadSaveTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(true);
    List<String> attributes = Arrays.asList("transName", "fileName", "directoryPath", "sourceStepName", "targetFile", "noExecution", "streamSourceStepname", "streamTargetStepname", "transObjectId", "specificationMethod", "sourceOutputFields");
    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("transObjectId", new ObjectIdLoadSaveValidator());
    attrValidatorMap.put("specificationMethod", new ObjectLocationSpecificationMethodLoadSaveValidator());
    attrValidatorMap.put("sourceOutputFields", new ListLoadSaveValidator<MetaInjectOutputField>(new MetaInjectOutputFieldLoadSaveValidator(), 5));
    // 
    // Note - these seem to be runtime-built and not persisted.
    // attrValidatorMap.put( "metaInjectMapping",
    // new ListLoadSaveValidator<MetaInjectMapping>( new MetaInjectMappingLoadSaveValidator(), 5 ) );
    // attrValidatorMap.put( "targetSourceMapping",
    // new MapLoadSaveValidator<TargetStepAttribute, SourceStepField>(
    // new TargetStepAttributeLoadSaveValidator(),
    // new SourceStepFieldLoadSaveValidator(),
    // 5 ) );
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Also used : ObjectLocationSpecificationMethodLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ObjectLocationSpecificationMethodLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) ObjectIdLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ObjectIdLoadSaveValidator) Before(org.junit.Before)

Example 8 with LoadSaveTester

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

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

the class RowsFromResultMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldname", "type", "length", "precision");
    Map<String, String> getterMap = new HashMap<String, String>();
    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("fieldname", stringArrayLoadSaveValidator);
    attrValidatorMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(7), 5));
    attrValidatorMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 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 : 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) ArrayList(java.util.ArrayList) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 10 with LoadSaveTester

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

the class RssInputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("includeRowNumber", "rowNumberField", "includeUrl", "urlField", "rowLimit", "readfrom", "urlInField", "urlFieldname", "url", "inputFields");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("includeRowNumber", "includeRowNumber");
            put("rowNumberField", "getRowNumberField");
            put("includeUrl", "includeUrl");
            put("urlField", "geturlField");
            put("rowLimit", "getRowLimit");
            put("readfrom", "getReadFrom");
            put("urlInField", "urlInField");
            put("urlFieldname", "getUrlFieldname");
            put("url", "getUrl");
            put("inputFields", "getInputFields");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("includeRowNumber", "setIncludeRowNumber");
            put("rowNumberField", "setRowNumberField");
            put("includeUrl", "setIncludeUrl");
            put("urlField", "seturlField");
            put("rowLimit", "setRowLimit");
            put("readfrom", "setReadFrom");
            put("urlInField", "seturlInField");
            put("urlFieldname", "setUrlFieldname");
            put("url", "setUrl");
            put("inputFields", "setInputFields");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<RssInputField[]> rssInputFieldArrayLoadSaveValidator = new ArrayLoadSaveValidator<RssInputField>(new RssInputFieldLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("url", stringArrayLoadSaveValidator);
    attrValidatorMap.put("inputFields", rssInputFieldArrayLoadSaveValidator);
    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)

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