Search in sources :

Example 71 with LoadSaveTester

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();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) Random(java.util.Random) TimeUnit(java.util.concurrent.TimeUnit) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 72 with LoadSaveTester

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();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) Test(org.junit.Test)

Example 73 with LoadSaveTester

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();
}
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 74 with LoadSaveTester

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();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) Test(org.junit.Test)

Example 75 with LoadSaveTester

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();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) Test(org.junit.Test)

Aggregations

LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)149 HashMap (java.util.HashMap)144 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)128 Before (org.junit.Before)86 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)81 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)67 Test (org.junit.Test)62 ArrayList (java.util.ArrayList)56 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)34 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)24 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)7 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)5 ObjectIdLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ObjectIdLoadSaveValidator)4 ObjectLocationSpecificationMethodLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ObjectLocationSpecificationMethodLoadSaveValidator)4 Matchers.anyString (org.mockito.Matchers.anyString)3 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)3 YNLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator)3