Search in sources :

Example 1 with StringLoadSaveValidator

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

the class WriteToLogMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("displayHeader", "limitRows", "limitRowsNumber", "logmessage", "loglevel", "fieldName");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("displayHeader", "isdisplayHeader");
            put("limitRows", "isLimitRows");
            put("limitRowsNumber", "getLimitRowsNumber");
            put("logmessage", "getLogMessage");
            put("loglevel", "getLogLevelString");
            put("fieldName", "getFieldName");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("displayHeader", "setdisplayHeader");
            put("limitRows", "setLimitRows");
            put("limitRowsNumber", "setLimitRowsNumber");
            put("logmessage", "setLogMessage");
            put("loglevel", "setLogLevelString");
            put("fieldName", "setFieldName");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("loglevel", new LogLevelLoadSaveValidator());
    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 2 with StringLoadSaveValidator

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

the class UniqueRowsMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("count_rows", "count_field", "reject_duplicate_row", "error_description", "name", "case_insensitive");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("count_rows", "isCountRows");
    getterMap.put("count_field", "getCountField");
    getterMap.put("reject_duplicate_row", "isRejectDuplicateRow");
    getterMap.put("error_description", "getErrorDescription");
    getterMap.put("name", "getCompareFields");
    getterMap.put("case_insensitive", "getCaseInsensitive");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("count_rows", "setCountRows");
    setterMap.put("count_field", "setCountField");
    setterMap.put("reject_duplicate_row", "setRejectDuplicateRow");
    setterMap.put("error_description", "setErrorDescription");
    setterMap.put("name", "setCompareFields");
    setterMap.put("case_insensitive", "setCaseInsensitive");
    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("name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("case_insensitive", booleanArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(UniqueRowsMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
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) Test(org.junit.Test)

Example 3 with StringLoadSaveValidator

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

the class YamlInputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("includeFilename", "filenameField", "includeRowNumber", "rowNumberField", "rowLimit", "encoding", "yamlField", "inFields", "IsAFile", "addResultFile", "validating", "IsIgnoreEmptyFile", "doNotFailIfNoFile", "fileName", "fileMask", "fileRequired", "includeSubFolders", "inputFields");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("includeFilename", "includeFilename");
            put("filenameField", "getFilenameField");
            put("includeRowNumber", "includeRowNumber");
            put("rowNumberField", "getRowNumberField");
            put("rowLimit", "getRowLimit");
            put("encoding", "getEncoding");
            put("yamlField", "getYamlField");
            put("inFields", "isInFields");
            put("IsAFile", "getIsAFile");
            put("addResultFile", "addResultFile");
            put("validating", "isValidating");
            put("IsIgnoreEmptyFile", "isIgnoreEmptyFile");
            put("doNotFailIfNoFile", "isdoNotFailIfNoFile");
            put("fileName", "getFileName");
            put("fileMask", "getFileMask");
            put("fileRequired", "getFileRequired");
            put("includeSubFolders", "getIncludeSubFolders");
            put("inputFields", "getInputFields");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("includeFilename", "setIncludeFilename");
            put("filenameField", "setFilenameField");
            put("includeRowNumber", "setIncludeRowNumber");
            put("rowNumberField", "setRowNumberField");
            put("rowLimit", "setRowLimit");
            put("encoding", "setEncoding");
            put("yamlField", "setYamlField");
            put("inFields", "setInFields");
            put("IsAFile", "setIsAFile");
            put("addResultFile", "setAddResultFile");
            put("validating", "setValidating");
            put("IsIgnoreEmptyFile", "setIgnoreEmptyFile");
            put("doNotFailIfNoFile", "setdoNotFailIfNoFile");
            put("fileName", "setFileName");
            put("fileMask", "setFileMask");
            put("fileRequired", "setFileRequired");
            put("includeSubFolders", "setIncludeSubFolders");
            put("inputFields", "setInputFields");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<YamlInputField[]> yamlInputFieldArrayLoadSaveValidator = new ArrayLoadSaveValidator<YamlInputField>(new YamlInputFieldLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fileName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fileRequired", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
    attrValidatorMap.put("includeSubFolders", stringArrayLoadSaveValidator);
    attrValidatorMap.put("inputFields", yamlInputFieldArrayLoadSaveValidator);
    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 4 with StringLoadSaveValidator

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

the class GaInputStepMetaTest method testSerialization.

@Test
public void testSerialization() throws KettleException {
    List<String> attributes = Arrays.asList("OAuthServiceAccount", "GaAppName", "OAuthKeyFile", "GaProfileName", "GaProfileTableId", "GaCustomTableId", "UseCustomTableId", "StartDate", "EndDate", "Dimensions", "Metrics", "Filters", "Sort", "UseSegment", "UseCustomSegment", "CustomSegment", "SegmentId", "SegmentName", "SamplingLevel", "RowLimit", "FeedFieldType", "FeedField", "OutputField", "OutputType", "ConversionMask");
    Map<String, FieldLoadSaveValidator<?>> attributeMap = new HashMap<>();
    Map<String, FieldLoadSaveValidator<?>> typeMap = new HashMap<>();
    int maxValueCount = ValueMetaFactory.getAllValueMetaNames().length;
    attributeMap.put("FeedField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("FeedFieldType", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("OutputField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("OutputType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(maxValueCount), 25));
    attributeMap.put("ConversionMask", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    LoadSaveTester<GaInputStepMeta> tester = new LoadSaveTester<>(GaInputStepMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), attributeMap, typeMap);
    tester.testSerialization();
}
Also used : 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) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 5 with StringLoadSaveValidator

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

the class RowGeneratorMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("neverEnding", "intervalInMs", "rowTimeField", "lastTimeField", "rowLimit", "currency", "decimal", "group", "value", "fieldName", "fieldType", "fieldFormat", "fieldLength", "fieldPrecision");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("neverEnding", "isNeverEnding");
            put("intervalInMs", "getIntervalInMs");
            put("rowTimeField", "getRowTimeField");
            put("lastTimeField", "getLastTimeField");
            put("rowLimit", "getRowLimit");
            put("currency", "getCurrency");
            put("decimal", "getDecimal");
            put("group", "getGroup");
            put("value", "getValue");
            put("fieldName", "getFieldName");
            put("fieldType", "getFieldType");
            put("fieldFormat", "getFieldFormat");
            put("fieldLength", "getFieldLength");
            put("fieldPrecision", "getFieldPrecision");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("neverEnding", "setNeverEnding");
            put("intervalInMs", "setIntervalInMs");
            put("rowTimeField", "setRowTimeField");
            put("lastTimeField", "setLastTimeField");
            put("rowLimit", "setRowLimit");
            put("currency", "setCurrency");
            put("decimal", "setDecimal");
            put("group", "setGroup");
            put("value", "setValue");
            put("fieldName", "setFieldName");
            put("fieldType", "setFieldType");
            put("fieldFormat", "setFieldFormat");
            put("fieldLength", "setFieldLength");
            put("fieldPrecision", "setFieldPrecision");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("currency", stringArrayLoadSaveValidator);
    attrValidatorMap.put("decimal", stringArrayLoadSaveValidator);
    attrValidatorMap.put("group", stringArrayLoadSaveValidator);
    attrValidatorMap.put("value", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldType", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldFormat", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldLength", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(100), 5));
    attrValidatorMap.put("fieldPrecision", 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 : 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)

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