use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class DatabaseLookupMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("schemaName", "tablename", "databaseMeta", "orderByClause", "cached", "cacheSize", "loadingAllDataInCache", "failingOnMultipleResults", "eatingRowOnLookupFailure", "streamKeyField1", "streamKeyField2", "keyCondition", "tableKeyField", "returnValueField", "returnValueNewName", "returnValueDefault", "returnValueDefaultType");
Map<String, String> getterMap = new HashMap<String, String>();
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("streamKeyField1", stringArrayLoadSaveValidator);
attrValidatorMap.put("streamKeyField2", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyCondition", stringArrayLoadSaveValidator);
attrValidatorMap.put("tableKeyField", stringArrayLoadSaveValidator);
attrValidatorMap.put("returnValueField", stringArrayLoadSaveValidator);
attrValidatorMap.put("returnValueNewName", stringArrayLoadSaveValidator);
attrValidatorMap.put("returnValueDefault", stringArrayLoadSaveValidator);
attrValidatorMap.put("returnValueDefaultType", new PrimitiveIntArrayLoadSaveValidator(new NonZeroIntLoadSaveValidator(7), 5));
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
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.FieldLoadSaveValidator 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.FieldLoadSaveValidator 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();
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class AbortMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("row_threshold", "message", "always_log_rows", "abort_option");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("row_threshold", "getRowThreshold");
getterMap.put("message", "getMessage");
getterMap.put("always_log_rows", "isAlwaysLogRows");
getterMap.put("abort_option", "getAbortOption");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("row_threshold", "setRowThreshold");
setterMap.put("message", "setMessage");
setterMap.put("always_log_rows", "setAlwaysLogRows");
setterMap.put("abort_option", "setAbortOption");
Map<String, FieldLoadSaveValidator<?>> attributeValidators = Collections.emptyMap();
Map<String, FieldLoadSaveValidator<?>> typeValidators = new HashMap<>();
typeValidators.put(AbortMeta.AbortOption.class.getCanonicalName(), new EnumLoadSaveValidator<>(AbortMeta.AbortOption.ABORT));
LoadSaveTester loadSaveTester = new LoadSaveTester(AbortMeta.class, attributes, getterMap, setterMap, attributeValidators, typeValidators);
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class AnalyticQueryMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("groupField", "aggregateField", "subjectField", "aggregateType", "valueField");
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> typeValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
Map<String, FieldLoadSaveValidator<?>> fieldValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
fieldValidators.put("aggregateField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
fieldValidators.put("subjectField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
fieldValidators.put("aggregateType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(AnalyticQueryMeta.typeGroupCode.length), 50));
fieldValidators.put("valueField", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 50));
LoadSaveTester loadSaveTester = new LoadSaveTester(AnalyticQueryMeta.class, attributes, getterMap, setterMap, fieldValidators, typeValidators);
loadSaveTester.testSerialization();
}
Aggregations