Search in sources :

Example 21 with LoadSaveTester

use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.

the class SortedMergeMetaTest method testRoundTrips.

@Test
public void testRoundTrips() throws KettleException {
    List<String> attributes = Arrays.asList("name", "ascending");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("name", "getFieldName");
    getterMap.put("ascending", "getAscending");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("name", "setFieldName");
    setterMap.put("ascending", "setAscending");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    FieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator = new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("ascending", booleanArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(SortedMergeMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 22 with LoadSaveTester

use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.

the class SQLFileOutputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("databaseMeta", "schemaName", "tablename", "truncateTable", "AddToResult", "createTable", "fileName", "extension", "splitEvery", "fileAppended", "stepNrInFilename", "dateInFilename", "timeInFilename", "encoding", "dateFormat", "StartNewLine", "createParentFolder", "DoNotOpenNewFileInit");
    // Note - "partNrInFilename" is used in serialization/deserialization, but there is no getter/setter for it and it's
    // not present in the dialog. Looks like a copy/paste thing, and the value itself will end up serialized/deserialized
    // as false.
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("truncateTable", "truncateTable");
            put("AddToResult", "AddToResult");
            put("createTable", "createTable");
            put("StartNewLine", "StartNewLine");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) Before(org.junit.Before)

Example 23 with LoadSaveTester

use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.

the class StepMetastructureMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("outputRowcount", "rowcountField");
    // At present, none of the other fields in StepMetastructureMeta are being persisted or read
    // All the other fields in the class are set from message bundles and not persisted. See default() method.
    // MB - 5/2016
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    LoadSaveTester loadSaveTester = new LoadSaveTester(StepMetastructureMeta.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 24 with LoadSaveTester

use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.

the class StepsMetricsMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("stepName", "stepCopyNr", "stepRequired", "stepnamefield", "stepidfield", "steplinesinputfield", "steplinesoutputfield", "steplinesreadfield", "steplinesupdatedfield", "steplineswrittentfield", "steplineserrorsfield", "stepsecondsfield");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("stepName", "getStepName");
            put("stepCopyNr", "getStepCopyNr");
            put("stepRequired", "getStepRequired");
            put("stepnamefield", "getStepNameFieldName");
            put("stepidfield", "getStepIdFieldName");
            put("steplinesinputfield", "getStepLinesInputFieldName");
            put("steplinesoutputfield", "getStepLinesOutputFieldName");
            put("steplinesreadfield", "getStepLinesReadFieldName");
            put("steplinesupdatedfield", "getStepLinesUpdatedFieldName");
            put("steplineswrittentfield", "getStepLinesWrittenFieldName");
            put("steplineserrorsfield", "getStepLinesErrorsFieldName");
            put("stepsecondsfield", "getStepSecondsFieldName");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("stepName", "setStepName");
            put("stepCopyNr", "setStepCopyNr");
            put("stepRequired", "setStepRequired");
            put("stepnamefield", "setStepNameFieldName");
            put("stepidfield", "setStepIdFieldName");
            put("steplinesinputfield", "setStepLinesInputFieldName");
            put("steplinesoutputfield", "setStepLinesOutputFieldName");
            put("steplinesreadfield", "setStepLinesReadFieldName");
            put("steplinesupdatedfield", "setStepLinesUpdatedFieldName");
            put("steplineswrittentfield", "setStepLinesWrittenFieldName");
            put("steplineserrorsfield", "setStepLinesErrorsFieldName");
            put("stepsecondsfield", "setStepSecondsFieldName");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("stepName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("stepCopyNr", stringArrayLoadSaveValidator);
    attrValidatorMap.put("stepRequired", stringArrayLoadSaveValidator);
    // attrValidatorMap.put( "setEmptyString",
    // new PrimitiveBooleanArrayLoadSaveValidator( new BooleanLoadSaveValidator(), 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);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) ArrayList(java.util.ArrayList) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 25 with LoadSaveTester

use of org.pentaho.di.trans.steps.loadsave.LoadSaveTester in project pentaho-kettle by pentaho.

the class StreamLookupMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("inputSorted", "memoryPreservationActive", "usingSortedList", "usingIntegerPair", "keystream", "keylookup", "value", "valueName", "valueDefault", "valueDefaultType");
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("keystream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keylookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("value", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueDefault", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueDefaultType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(7), 5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), new HashMap<String, String>(), new HashMap<String, String>(), attrValidatorMap, typeValidatorMap, this);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) 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) ArrayList(java.util.ArrayList) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

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