Search in sources :

Example 91 with LoadSaveTester

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

the class ReplaceStringMetaTest method testRoundTrips.

@Test
public void testRoundTrips() throws KettleException {
    List<String> attributes = Arrays.asList("in_stream_name", "out_stream_name", "use_regex", "replace_string", "replace_by_string", "set_empty_string", "replace_field_by_string", "whole_word", "case_sensitive", "is_unicode");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("in_stream_name", "getFieldInStream");
    getterMap.put("out_stream_name", "getFieldOutStream");
    getterMap.put("use_regex", "getUseRegEx");
    getterMap.put("replace_string", "getReplaceString");
    getterMap.put("replace_by_string", "getReplaceByString");
    getterMap.put("set_empty_string", "isSetEmptyString");
    getterMap.put("replace_field_by_string", "getFieldReplaceByString");
    getterMap.put("whole_word", "getWholeWord");
    getterMap.put("case_sensitive", "getCaseSensitive");
    getterMap.put("is_unicode", "isUnicode");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("in_stream_name", "setFieldInStream");
    setterMap.put("out_stream_name", "setFieldOutStream");
    setterMap.put("use_regex", "setUseRegEx");
    setterMap.put("replace_string", "setReplaceString");
    setterMap.put("replace_by_string", "setReplaceByString");
    setterMap.put("set_empty_string", "setEmptyString");
    setterMap.put("replace_field_by_string", "setFieldReplaceByString");
    setterMap.put("whole_word", "setWholeWord");
    setterMap.put("case_sensitive", "setCaseSensitive");
    setterMap.put("is_unicode", "setIsUnicode");
    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);
    FieldLoadSaveValidator<int[]> useRegExArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.useRegExCode.length), 25);
    FieldLoadSaveValidator<int[]> wholeWordArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.wholeWordCode.length), 25);
    FieldLoadSaveValidator<int[]> caseSensitiveArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.caseSensitiveCode.length), 25);
    FieldLoadSaveValidator<int[]> isUnicodeArrayLoadSaveValidator = new PrimitiveIntegerArrayLoadSaveValidator(new IntLoadSaveValidator(ReplaceStringMeta.isUnicodeCode.length), 25);
    fieldLoadSaveValidatorAttributeMap.put("in_stream_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("out_stream_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("use_regex", useRegExArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("replace_string", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("replace_by_string", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("set_empty_string", booleanArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("replace_field_by_string", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("whole_word", wholeWordArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("case_sensitive", caseSensitiveArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("is_unicode", isUnicodeArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(ReplaceStringMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
Also used : PrimitiveIntegerArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntegerArrayLoadSaveValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveIntegerArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntegerArrayLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) 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) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) Mockito.anyString(org.mockito.Mockito.anyString) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 92 with LoadSaveTester

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

the class RestMetaTest method testLoadSaveRoundTrip.

@Test
public void testLoadSaveRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("applicationType", "method", "url", "urlInField", "dynamicMethod", "methodFieldName", "urlField", "bodyField", "httpLogin", "httpPassword", "proxyHost", "proxyPort", "preemptive", "trustStoreFile", "trustStorePassword", "headerField", "headerName", "parameterField", "parameterName", "matrixParameterField", "matrixParameterName", "fieldName", "resultCodeFieldName", "responseTimeFieldName", "responseHeaderFieldName");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    // Arrays need to be consistent length
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    fieldLoadSaveValidatorAttributeMap.put("headerField", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("headerName", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("parameterField", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("parameterName", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("matrixParameterField", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("matrixParameterName", stringArrayLoadSaveValidator);
    LoadSaveTester<RestMeta> loadSaveTester = new LoadSaveTester<RestMeta>(RestMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 93 with LoadSaveTester

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

the class DenormalizerMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("groupField", "keyField", "denormaliserTargetField");
    Map<String, String> getterMap = new HashMap<String, String>() {

        // CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
        {
        // put( "fieldName", "getFieldName" );
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        // CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
        {
        // put( "fieldName", "setFieldName" );
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("groupField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("denormaliserTargetField", new ArrayLoadSaveValidator<DenormaliserTargetField>(new DenormaliserTargetFieldLoadSaveValidator(), 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 94 with LoadSaveTester

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

the class DimensionLookupMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    List<String> attributes = Arrays.asList("schemaName", "tableName", "update", "dateField", "dateFrom", "dateTo", "keyField", "keyRename", "autoIncrement", "versionField", "commitSize", "useBatchUpdate", "minYear", "maxYear", "techKeyCreation", "cacheSize", "usingStartDateAlternative", "startDateAlternative", "startDateFieldName", "preloadingCache", "keyStream", "keyLookup", "fieldStream", "fieldLookup", "fieldUpdate", "databaseMeta", "sequenceName");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("useBatchUpdate", "useBatchUpdate");
        }
    };
    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("keyStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyLookup", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldLookup", stringArrayLoadSaveValidator);
    // Note - have to use the non-zero int load/save validator here because if "update"
    // is false, code in DimensionLookupMeta replaces "ValueMetaInterface.TYPE_NONE" with
    // ValueMetaInterface.TYPE_STRING. This happens about once out of every 3 or so runs of
    // the test which made it a bit difficult to track down.
    // MB - 5/2016
    attrValidatorMap.put("fieldUpdate", new FieldUpdateIntArrayLoadSaveValidator(new NonZeroIntLoadSaveValidator(DimensionLookupMeta.typeDesc.length), 5));
    attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
    attrValidatorMap.put("startDateAlternative", new IntLoadSaveValidator(DimensionLookupMeta.getStartDateAlternativeCodes().length));
    attrValidatorMap.put("sequenceName", new SequenceNameLoadSaveValidator());
    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 : PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) NonZeroIntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator) IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) NonZeroIntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator) 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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Matchers.anyString(org.mockito.Matchers.anyString) DatabaseMetaLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 95 with LoadSaveTester

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

the class Edi2XmlMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("inputfield", "outputfield");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("inputfield", "getInputField");
    getterMap.put("outputfield", "getOutputField");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("inputfield", "setInputField");
    setterMap.put("outputfield", "setOutputField");
    LoadSaveTester loadSaveTester = new LoadSaveTester(Edi2XmlMeta.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