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);
}
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();
}
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);
}
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();
}
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);
}
Aggregations