Search in sources :

Example 11 with FieldLoadSaveValidator

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

the class RssOutputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("channeltitle", "channeldescription", "channellink", "channelpubdate", "channelcopyright", "channelimagetitle", "channelimagelink", "channelimageurl", "channelimagedescription", "channellanguage", "channelauthor", "itemtitle", "itemdescription", "itemlink", "itempubdate", "itemauthor", "geopointlat", "geopointlong", "AddToResult", "fileName", "extension", "stepNrInFilename", "partNrInFilename", "dateInFilename", "timeInFilename", "createparentfolder", "version", "encoding", "addimage", "addgeorss", "usegeorssgml", "filenamefield", "isfilenameinfield", "customrss", "displayitem", "ChannelCustomFields", "NameSpaces", "NameSpacesTitle", "ChannelCustomTags", "ItemCustomFields", "ItemCustomTags");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("channeltitle", "getChannelTitle");
            put("channeldescription", "getChannelDescription");
            put("channellink", "getChannelLink");
            put("channelpubdate", "getChannelPubDate");
            put("channelcopyright", "getChannelCopyright");
            put("channelimagetitle", "getChannelImageTitle");
            put("channelimagelink", "getChannelImageLink");
            put("channelimageurl", "getChannelImageUrl");
            put("channelimagedescription", "getChannelImageDescription");
            put("channellanguage", "getChannelLanguage");
            put("channelauthor", "getChannelAuthor");
            put("itemtitle", "getItemTitle");
            put("itemdescription", "getItemDescription");
            put("itemlink", "getItemLink");
            put("itempubdate", "getItemPubDate");
            put("itemauthor", "getItemAuthor");
            put("geopointlat", "getGeoPointLat");
            put("geopointlong", "getGeoPointLong");
            put("AddToResult", "AddToResult");
            put("fileName", "getFileName");
            put("extension", "getExtension");
            put("stepNrInFilename", "isStepNrInFilename");
            put("partNrInFilename", "isPartNrInFilename");
            put("dateInFilename", "isDateInFilename");
            put("timeInFilename", "isTimeInFilename");
            put("createparentfolder", "isCreateParentFolder");
            put("version", "getVersion");
            put("encoding", "getEncoding");
            put("addimage", "AddImage");
            put("addgeorss", "AddGeoRSS");
            put("usegeorssgml", "useGeoRSSGML");
            put("filenamefield", "getFileNameField");
            put("isfilenameinfield", "isFilenameInField");
            put("customrss", "isCustomRss");
            put("displayitem", "isDisplayItem");
            put("ChannelCustomFields", "getChannelCustomFields");
            put("NameSpaces", "getNameSpaces");
            put("NameSpacesTitle", "getNameSpacesTitle");
            put("ChannelCustomTags", "getChannelCustomTags");
            put("ItemCustomFields", "getItemCustomFields");
            put("ItemCustomTags", "getItemCustomTags");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("channeltitle", "setChannelTitle");
            put("channeldescription", "setChannelDescription");
            put("channellink", "setChannelLink");
            put("channelpubdate", "setChannelPubDate");
            put("channelcopyright", "setChannelCopyright");
            put("channelimagetitle", "setChannelImageTitle");
            put("channelimagelink", "setChannelImageLink");
            put("channelimageurl", "setChannelImageUrl");
            put("channelimagedescription", "setChannelImageDescription");
            put("channellanguage", "setChannelLanguage");
            put("channelauthor", "setChannelAuthor");
            put("itemtitle", "setItemTitle");
            put("itemdescription", "setItemDescription");
            put("itemlink", "setItemLink");
            put("itempubdate", "setItemPubDate");
            put("itemauthor", "setItemAuthor");
            put("geopointlat", "setGeoPointLat");
            put("geopointlong", "setGeoPointLong");
            put("AddToResult", "setAddToResult");
            put("fileName", "setFileName");
            put("extension", "setExtension");
            put("stepNrInFilename", "setStepNrInFilename");
            put("partNrInFilename", "setPartNrInFilename");
            put("dateInFilename", "setDateInFilename");
            put("timeInFilename", "setTimeInFilename");
            put("createparentfolder", "setCreateParentFolder");
            put("version", "setVersion");
            put("encoding", "setEncoding");
            put("addimage", "setAddImage");
            put("addgeorss", "setAddGeoRSS");
            put("usegeorssgml", "setUseGeoRSSGML");
            put("filenamefield", "setFileNameField");
            put("isfilenameinfield", "setFilenameInField");
            put("customrss", "setCustomRss");
            put("displayitem", "setDisplayItem");
            put("ChannelCustomFields", "setChannelCustomFields");
            put("NameSpaces", "setNameSpaces");
            put("NameSpacesTitle", "setNameSpacesTitle");
            put("ChannelCustomTags", "setChannelCustomTags");
            put("ItemCustomFields", "setItemCustomFields");
            put("ItemCustomTags", "setItemCustomTags");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("ChannelCustomFields", stringArrayLoadSaveValidator);
    attrValidatorMap.put("NameSpaces", stringArrayLoadSaveValidator);
    attrValidatorMap.put("NameSpacesTitle", stringArrayLoadSaveValidator);
    attrValidatorMap.put("ChannelCustomTags", stringArrayLoadSaveValidator);
    attrValidatorMap.put("ItemCustomFields", stringArrayLoadSaveValidator);
    attrValidatorMap.put("ItemCustomTags", stringArrayLoadSaveValidator);
    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 12 with FieldLoadSaveValidator

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

the class SasInputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("acceptingField", "outputFields");
    Map<String, String> gsMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("outputFields", new ListLoadSaveValidator<SasInputField>(new SasInputFieldLoadSaveValidator(), 5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, gsMap, gsMap, attrValidatorMap, typeValidatorMap);
}
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 13 with FieldLoadSaveValidator

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

the class ScriptMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldname", "rename", "type", "length", "precision", "replace", "jsScripts");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fieldname", "getFieldname");
            put("rename", "getRename");
            put("type", "getType");
            put("length", "getLength");
            put("precision", "getPrecision");
            put("replace", "getReplace");
            put("jsScripts", "getJSScripts");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fieldname", "setFieldname");
            put("rename", "setRename");
            put("type", "setType");
            put("length", "setLength");
            put("precision", "setPrecision");
            put("replace", "setReplace");
            put("jsScripts", "setJSScripts");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<ScriptValuesScript[]> svsArrayLoadSaveValidator = new ArrayLoadSaveValidator<ScriptValuesScript>(new ScriptValuesScriptLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldname", stringArrayLoadSaveValidator);
    attrValidatorMap.put("rename", stringArrayLoadSaveValidator);
    attrValidatorMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 5));
    attrValidatorMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(6), 5));
    attrValidatorMap.put("replace", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5));
    attrValidatorMap.put("jsScripts", svsArrayLoadSaveValidator);
    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) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) 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) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 14 with FieldLoadSaveValidator

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

the class ScriptValuesMetaModTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("fieldname", "rename", "type", "length", "precision", "replace", "jsScripts", "compatible", "optimizationLevel");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("fieldname", "getFieldname");
            put("rename", "getRename");
            put("type", "getType");
            put("length", "getLength");
            put("precision", "getPrecision");
            put("replace", "getReplace");
            put("compatible", "isCompatible");
            put("optimizationLevel", "getOptimizationLevel");
            put("jsScripts", "getJSScripts");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("fieldname", "setFieldname");
            put("rename", "setRename");
            put("type", "setType");
            put("length", "setLength");
            put("precision", "setPrecision");
            put("replace", "setReplace");
            put("compatible", "setCompatible");
            put("optimizationLevel", "setOptimizationLevel");
            put("jsScripts", "setJSScripts");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<ScriptValuesScript[]> svsArrayLoadSaveValidator = new ArrayLoadSaveValidator<ScriptValuesScript>(new ScriptValuesScriptLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldname", stringArrayLoadSaveValidator);
    attrValidatorMap.put("rename", stringArrayLoadSaveValidator);
    attrValidatorMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(9), 5));
    attrValidatorMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(6), 5));
    attrValidatorMap.put("replace", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5));
    attrValidatorMap.put("jsScripts", svsArrayLoadSaveValidator);
    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) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) 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) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 15 with FieldLoadSaveValidator

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

the class SelectValuesMetaTest method loadSaveTest.

@Test
public void loadSaveTest() throws KettleException {
    List<String> attributes = Arrays.asList("selectFields", "deleteName");
    SelectField selectField = new SelectField();
    selectField.setName("TEST_NAME");
    selectField.setRename("TEST_RENAME");
    selectField.setLength(2);
    selectField.setPrecision(2);
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorTypeMap.put(SelectField[].class.getCanonicalName(), new ArrayLoadSaveValidator<SelectField>(new SelectFieldLoadSaveValidator(selectField), 2));
    LoadSaveTester tester = new LoadSaveTester(SelectValuesMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), new HashMap<String, FieldLoadSaveValidator<?>>(), fieldLoadSaveValidatorTypeMap);
    tester.testSerialization();
}
Also used : SelectField(org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta.SelectField) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) Test(org.junit.Test)

Aggregations

FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)154 HashMap (java.util.HashMap)147 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)128 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)90 Before (org.junit.Before)89 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)72 ArrayList (java.util.ArrayList)59 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)47 Test (org.junit.Test)44 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)31 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)22 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)16 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)14 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)9 Random (java.util.Random)6 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 Repository (org.pentaho.di.repository.Repository)4 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)4