use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester 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.LoadSaveTester 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.LoadSaveTester 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();
}
use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.
the class BlockingStepMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("pass_all_rows", "directory", "prefix", "cache_size", "compress");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("pass_all_rows", "isPassAllRows");
getterMap.put("directory", "getDirectory");
getterMap.put("prefix", "getPrefix");
getterMap.put("cache_size", "getCacheSize");
getterMap.put("compress", "getCompress");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("pass_all_rows", "setPassAllRows");
setterMap.put("directory", "setDirectory");
setterMap.put("prefix", "setPrefix");
setterMap.put("cache_size", "setCacheSize");
setterMap.put("compress", "setCompress");
LoadSaveTester loadSaveTester = new LoadSaveTester(BlockingStepMeta.class, attributes, getterMap, setterMap);
loadSaveTester.testSerialization();
}
use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.
the class CloneRowMetaTest method testRoundTrip.
@Test
public void testRoundTrip() throws KettleException {
List<String> attributes = Arrays.asList("nrclones", "addcloneflag", "cloneflagfield", "nrcloneinfield", "nrclonefield", "addclonenum", "clonenumfield");
Map<String, String> getterMap = new HashMap<String, String>();
getterMap.put("nrclones", "getNrClones");
getterMap.put("addcloneflag", "isAddCloneFlag");
getterMap.put("cloneflagfield", "getCloneFlagField");
getterMap.put("nrcloneinfield", "isNrCloneInField");
getterMap.put("nrclonefield", "getNrCloneField");
getterMap.put("addclonenum", "isAddCloneNum");
getterMap.put("clonenumfield", "getCloneNumField");
Map<String, String> setterMap = new HashMap<String, String>();
setterMap.put("nrclones", "setNrClones");
setterMap.put("addcloneflag", "setAddCloneFlag");
setterMap.put("cloneflagfield", "setCloneFlagField");
setterMap.put("nrcloneinfield", "setNrCloneInField");
setterMap.put("nrclonefield", "setNrCloneField");
setterMap.put("addclonenum", "setAddCloneNum");
setterMap.put("clonenumfield", "setCloneNumField");
LoadSaveTester loadSaveTester = new LoadSaveTester(CloneRowMeta.class, attributes, getterMap, setterMap);
loadSaveTester.testSerialization();
}
Aggregations