Search in sources :

Example 11 with StringLoadSaveValidator

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

Example 12 with StringLoadSaveValidator

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

the class StreamLookupMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("inputSorted", "memoryPreservationActive", "usingSortedList", "usingIntegerPair", "keystream", "keylookup", "value", "valueName", "valueDefault", "valueDefaultType");
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("keystream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keylookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("value", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueDefault", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueDefaultType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(7), 5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), new HashMap<String, String>(), new HashMap<String, String>(), attrValidatorMap, typeValidatorMap, this);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) 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 13 with StringLoadSaveValidator

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

the class ElasticSearchBulkMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("index", "type", "batchSize", "timeout", "timeoutUnit", "isJson", "jsonField", "idOutputField", "idField", "overwriteIfExists", "useOutput", "stopOnError", "fields", "servers", "settings");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("index", "getIndex");
    getterMap.put("type", "getType");
    getterMap.put("batchSize", "getBatchSize");
    getterMap.put("timeout", "getTimeOut");
    getterMap.put("timeoutUnit", "getTimeoutUnit");
    getterMap.put("isJson", "isJsonInsert");
    getterMap.put("jsonField", "getJsonField");
    getterMap.put("idOutputField", "getIdOutField");
    getterMap.put("idField", "getIdInField");
    getterMap.put("overwriteIfExists", "isOverWriteIfSameId");
    getterMap.put("useOutput", "isUseOutput");
    getterMap.put("stopOnError", "isStopOnError");
    getterMap.put("fields", "getFieldsMap");
    getterMap.put("servers", "getServers");
    getterMap.put("settings", "getSettingsMap");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("index", "setIndex");
    setterMap.put("type", "setType");
    setterMap.put("batchSize", "setBatchSize");
    setterMap.put("timeout", "setTimeOut");
    setterMap.put("timeoutUnit", "setTimeoutUnit");
    setterMap.put("isJson", "setJsonInsert");
    setterMap.put("jsonField", "setJsonField");
    setterMap.put("idOutputField", "setIdOutField");
    setterMap.put("idField", "setIdInField");
    setterMap.put("overwriteIfExists", "setOverWriteIfSameId");
    setterMap.put("useOutput", "setUseOutput");
    setterMap.put("stopOnError", "setStopOnError");
    setterMap.put("fields", "setFieldsMap");
    setterMap.put("servers", "setServers");
    setterMap.put("settings", "setSettingsMap");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorAttributeMap.put("fields", new MapLoadSaveValidator<String, String>(new StringLoadSaveValidator(), new StringLoadSaveValidator()));
    fieldLoadSaveValidatorAttributeMap.put("settings", new MapLoadSaveValidator<String, String>(new StringLoadSaveValidator(), new StringLoadSaveValidator()));
    fieldLoadSaveValidatorAttributeMap.put("servers", new ListLoadSaveValidator<ElasticSearchBulkMeta.Server>(new FieldLoadSaveValidator<ElasticSearchBulkMeta.Server>() {

        Random rand = new Random();

        @Override
        public ElasticSearchBulkMeta.Server getTestObject() {
            ElasticSearchBulkMeta.Server r = new ElasticSearchBulkMeta.Server();
            r.address = rand.nextLong() + "";
            r.port = rand.nextInt();
            return r;
        }

        @Override
        public boolean validateTestObject(ElasticSearchBulkMeta.Server testObject, Object actual) {
            ElasticSearchBulkMeta.Server ac = (ElasticSearchBulkMeta.Server) actual;
            return ac.address.equals(testObject.address) && ac.port == testObject.port;
        }
    }));
    fieldLoadSaveValidatorTypeMap.put(TimeUnit.class.getCanonicalName(), new TimeUnitFieldLoadSaveValidator());
    LoadSaveTester loadSaveTester = new LoadSaveTester(ElasticSearchBulkMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, fieldLoadSaveValidatorTypeMap);
    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) Random(java.util.Random) TimeUnit(java.util.concurrent.TimeUnit) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 14 with StringLoadSaveValidator

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

the class GroupByMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("passAllRows", "directory", "prefix", "aggregateIgnored", "aggregateIgnoredField", "addingLineNrInGroup", "lineNrInGroupField", "alwaysGivingBackOneRow", "groupField", "aggregateField", "subjectField", "aggregateType", "valueField");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("passAllRows", "passAllRows");
        }
    };
    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("groupField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("aggregateField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("subjectField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("aggregateType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(GroupByMeta.typeGroupCode.length), 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 15 with StringLoadSaveValidator

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

the class HTTPPOSTMetaTest method testLoadSaveRoundTrip.

@Before
public void testLoadSaveRoundTrip() throws KettleException {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("postAFile", "encoding", "url", "urlInField", "urlField", "requestEntity", "httpLogin", "httpPassword", "proxyHost", "proxyPort", "socketTimeout", "connectionTimeout", "closeIdleConnectionsTime", "argumentField", "argumentParameter", "argumentHeader", "queryField", "queryParameter", "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);
    FieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("argumentField", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("argumentParameter", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("argumentHeader", booleanArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("queryField", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("queryParameter", stringArrayLoadSaveValidator);
    loadSaveTester = new LoadSaveTester(HTTPPOSTMeta.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) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) 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) 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