use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class MySQLBulkLoaderMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList(/*"connection",*/
"schema", "table", "encoding", "delimiter", "enclosure", "escape_char", "replace", "ignore", "local", "fifo_file_name", "bulk_size", "stream_name", "field_name", "field_format_ok");
Map<String, String> getterMap = new HashMap<String, String>();
// getterMap.put( "connection", "" );
getterMap.put("schema", "getSchemaName");
getterMap.put("table", "getTableName");
getterMap.put("encoding", "getEncoding");
getterMap.put("delimiter", "getDelimiter");
getterMap.put("enclosure", "getEnclosure");
getterMap.put("escape_char", "getEscapeChar");
getterMap.put("replace", "isReplacingData");
getterMap.put("ignore", "isIgnoringErrors");
getterMap.put("local", "isLocalFile");
getterMap.put("fifo_file_name", "getFifoFileName");
getterMap.put("bulk_size", "getBulkSize");
getterMap.put("stream_name", "getFieldTable");
getterMap.put("field_name", "getFieldStream");
getterMap.put("field_format_ok", "getFieldFormatType");
Map<String, String> setterMap = new HashMap<String, String>();
// setterMap.put( "connection", "" );
setterMap.put("schema", "setSchemaName");
setterMap.put("table", "setTableName");
setterMap.put("encoding", "setEncoding");
setterMap.put("delimiter", "setDelimiter");
setterMap.put("enclosure", "setEnclosure");
setterMap.put("escape_char", "setEscapeChar");
setterMap.put("replace", "setReplacingData");
setterMap.put("ignore", "setIgnoringErrors");
setterMap.put("local", "setLocalFile");
setterMap.put("fifo_file_name", "setFifoFileName");
setterMap.put("bulk_size", "setBulkSize");
setterMap.put("stream_name", "setFieldTable");
setterMap.put("field_name", "setFieldStream");
setterMap.put("field_format_ok", "setFieldFormatType");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
FieldLoadSaveValidator<int[]> fieldFormatTypeArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(MySQLBulkLoaderMeta.getFieldFormatTypeCodes().length), 25);
fieldLoadSaveValidatorAttributeMap.put("stream_name", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("field_name", stringArrayLoadSaveValidator);
fieldLoadSaveValidatorAttributeMap.put("field_format_ok", fieldFormatTypeArrayLoadSaveValidator);
LoadSaveTester loadSaveTester = new LoadSaveTester(MySQLBulkLoaderMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator 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);
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator 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);
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class ExcelInputMetaTest method testRepoRoundTripWithNullAttr.
@Test
public void testRepoRoundTripWithNullAttr() throws KettleException {
List<String> attributes = Arrays.asList("fileName", "fileMask", "excludeFileMask", "fileRequired", "includeSubFolders", "field", "sheetName", "startRow", "startColumn", "spreadSheetType", "fileField", "sheetField", "sheetRowNumberField", "rowNumberField", "shortFileFieldName", "extensionFieldName", "pathFieldName", "sizeFieldName", "hiddenFieldName", "lastModificationTimeFieldName", "uriNameFieldName", "rootUriNameFieldName");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("excludeFileMask", "getExludeFileMask");
put("shortFileFieldName", "getShortFileNameField");
put("extensionFieldName", "getExtensionField");
put("pathFieldName", "getPathField");
put("sizeFieldName", "getSizeField");
put("hiddenFieldName", "isHiddenField");
put("lastModificationTimeFieldName", "getLastModificationDateField");
put("uriNameFieldName", "getUriField");
put("rootUriNameFieldName", "getRootUriField");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("shortFileFieldName", "setShortFileNameField");
put("extensionFieldName", "setExtensionField");
put("pathFieldName", "setPathField");
put("sizeFieldName", "setSizeField");
put("hiddenFieldName", "setIsHiddenField");
put("lastModificationTimeFieldName", "setLastModificationDateField");
put("uriNameFieldName", "setUriField");
put("rootUriNameFieldName", "setRootUriField");
}
};
FieldLoadSaveValidator<String[]> nullStringArrayLoadSaveValidator = new NullStringArrayLoadSaveValidator();
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 1);
NullNameExcelInputArrayFieldLoadSaveValidator nullNameExcelInputArrayFieldLoadSaveValidator = new NullNameExcelInputArrayFieldLoadSaveValidator();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fileName", nullStringArrayLoadSaveValidator);
attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
attrValidatorMap.put("fileRequired", stringArrayLoadSaveValidator);
attrValidatorMap.put("includeSubFolders", stringArrayLoadSaveValidator);
attrValidatorMap.put("sheetName", nullStringArrayLoadSaveValidator);
attrValidatorMap.put("field", nullNameExcelInputArrayFieldLoadSaveValidator);
attrValidatorMap.put("spreadSheetType", new SpreadSheetTypeFieldLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 1));
loadSaveTester = new LoadSaveTester(ExcelInputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
loadSaveTester.testRepoRoundTrip();
}
use of org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator in project pentaho-kettle by pentaho.
the class FieldSplitterMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("splitfield", "delimiter", "enclosure", "name", "id", "idrem", "type", "format", "group", "decimal", "currency", "length", "precision", "nullif", "ifnull", "trimtype");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("splitfield", "getSplitField");
getterMap.put("delimiter", "getDelimiter");
getterMap.put("enclosure", "getEnclosure");
getterMap.put("name", "getFieldName");
getterMap.put("id", "getFieldID");
getterMap.put("idrem", "getFieldRemoveID");
getterMap.put("type", "getFieldType");
getterMap.put("format", "getFieldFormat");
getterMap.put("group", "getFieldGroup");
getterMap.put("decimal", "getFieldDecimal");
getterMap.put("currency", "getFieldCurrency");
getterMap.put("length", "getFieldLength");
getterMap.put("precision", "getFieldPrecision");
getterMap.put("nullif", "getFieldNullIf");
getterMap.put("ifnull", "getFieldIfNull");
getterMap.put("trimtype", "getFieldTrimType");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("splitfield", "setSplitField");
setterMap.put("delimiter", "setDelimiter");
setterMap.put("enclosure", "setEnclosure");
setterMap.put("name", "setFieldName");
setterMap.put("id", "setFieldID");
setterMap.put("idrem", "setFieldRemoveID");
setterMap.put("type", "setFieldType");
setterMap.put("format", "setFieldFormat");
setterMap.put("group", "setFieldGroup");
setterMap.put("decimal", "setFieldDecimal");
setterMap.put("currency", "setFieldCurrency");
setterMap.put("length", "setFieldLength");
setterMap.put("precision", "setFieldPrecision");
setterMap.put("nullif", "setFieldNullIf");
setterMap.put("ifnull", "setFieldIfNull");
setterMap.put("trimtype", "setFieldTrimType");
Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
fieldLoadSaveValidatorAttributeMap.put("name", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("id", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("idrem", new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaFactory.getAllValueMetaNames().length), 5));
fieldLoadSaveValidatorAttributeMap.put("format", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("group", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("decimal", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("currency", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("length", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("precision", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("nullif", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("ifnull", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
fieldLoadSaveValidatorAttributeMap.put("trimtype", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ValueMetaBase.getTrimTypeCodes().length), 5));
LoadSaveTester loadSaveTester = new LoadSaveTester(FieldSplitterMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
loadSaveTester.testSerialization();
}
Aggregations