Search in sources :

Example 31 with LoadSaveTester

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

the class MultiMergeJoinMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    multiMergeMeta = new MultiMergeJoinMeta();
    List<String> attributes = Arrays.asList("joinType", "keyFields", "inputSteps");
    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("keyFields", stringArrayLoadSaveValidator);
    attrValidatorMap.put("inputSteps", stringArrayLoadSaveValidator);
    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 32 with LoadSaveTester

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

the class MySQLBulkLoaderMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList(/*"connection",*/
    "schema", "table", "encoding", "delimiter", "enclosure", "escape_char", "replace", "ignore", "local", "fifo_file_name", "bulk_size", "stream_name", "field_name", "field_format_ok");
    Map<String, String> getterMap = new HashMap<String, String>();
    // getterMap.put( "connection", "" );
    getterMap.put("schema", "getSchemaName");
    getterMap.put("table", "getTableName");
    getterMap.put("encoding", "getEncoding");
    getterMap.put("delimiter", "getDelimiter");
    getterMap.put("enclosure", "getEnclosure");
    getterMap.put("escape_char", "getEscapeChar");
    getterMap.put("replace", "isReplacingData");
    getterMap.put("ignore", "isIgnoringErrors");
    getterMap.put("local", "isLocalFile");
    getterMap.put("fifo_file_name", "getFifoFileName");
    getterMap.put("bulk_size", "getBulkSize");
    getterMap.put("stream_name", "getFieldTable");
    getterMap.put("field_name", "getFieldStream");
    getterMap.put("field_format_ok", "getFieldFormatType");
    Map<String, String> setterMap = new HashMap<String, String>();
    // setterMap.put( "connection", "" );
    setterMap.put("schema", "setSchemaName");
    setterMap.put("table", "setTableName");
    setterMap.put("encoding", "setEncoding");
    setterMap.put("delimiter", "setDelimiter");
    setterMap.put("enclosure", "setEnclosure");
    setterMap.put("escape_char", "setEscapeChar");
    setterMap.put("replace", "setReplacingData");
    setterMap.put("ignore", "setIgnoringErrors");
    setterMap.put("local", "setLocalFile");
    setterMap.put("fifo_file_name", "setFifoFileName");
    setterMap.put("bulk_size", "setBulkSize");
    setterMap.put("stream_name", "setFieldTable");
    setterMap.put("field_name", "setFieldStream");
    setterMap.put("field_format_ok", "setFieldFormatType");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    FieldLoadSaveValidator<int[]> fieldFormatTypeArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(MySQLBulkLoaderMeta.getFieldFormatTypeCodes().length), 25);
    fieldLoadSaveValidatorAttributeMap.put("stream_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("field_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("field_format_ok", fieldFormatTypeArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(MySQLBulkLoaderMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
Also used : PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) 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 33 with LoadSaveTester

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

the class NormalizerMetaTest method loadSaveTest.

@Test
public void loadSaveTest() throws KettleException {
    List<String> attributes = Arrays.asList("normaliserFields");
    NormaliserField testField = new NormaliserField();
    testField.setName("TEST_NAME");
    testField.setValue("TEST_VALUE");
    testField.setNorm("TEST");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorTypeMap.put(NormaliserField[].class.getCanonicalName(), new ArrayLoadSaveValidator<NormaliserField>(new NormaliserFieldLoadSaveValidator(testField), 50));
    LoadSaveTester<NormaliserMeta> tester = new LoadSaveTester<NormaliserMeta>(NormaliserMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), new HashMap<String, FieldLoadSaveValidator<?>>(), fieldLoadSaveValidatorTypeMap);
    tester.testSerialization();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) NormaliserField(org.pentaho.di.trans.steps.normaliser.NormaliserMeta.NormaliserField) NormaliserMeta(org.pentaho.di.trans.steps.normaliser.NormaliserMeta) Test(org.junit.Test)

Example 34 with LoadSaveTester

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

the class NumberRangeMetaTest method testStepMeta.

@Test
public void testStepMeta() throws KettleException {
    List<String> attributes = Arrays.asList("inputField", "outputField", "fallBackValue", "rules");
    Map<String, String> getterMap = new HashMap<String, String>();
    getterMap.put("inputField", "getInputField");
    getterMap.put("outputField", "getOutputField");
    getterMap.put("fallBackValue", "getFallBackValue");
    getterMap.put("rules", "getRules");
    Map<String, String> setterMap = new HashMap<String, String>();
    setterMap.put("inputField", "setInputField");
    setterMap.put("outputField", "setOutputField");
    setterMap.put("fallBackValue", "setFallBackValue");
    setterMap.put("rules", "setRules");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldLoadSaveValidatorAttributeMap.put("rules", new ListLoadSaveValidator<NumberRangeRule>(new NumberRangeRuleFieldLoadSaveValidator(), 25));
    LoadSaveTester loadSaveTester = new LoadSaveTester(NumberRangeMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    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 35 with LoadSaveTester

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

the class OraBulkLoaderMetaTest method setUp.

@Before
public void setUp() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("schemaName", "tableName", "sqlldr", "controlFile", "dataFile", "logFile", "badFile", "discardFile", "commitSize", "bindSize", "readSize", "maxErrors", "loadMethod", "loadAction", "encoding", "characterSetName", "directPath", "eraseFiles", "dbNameOverride", "failOnWarning", "failOnError", "parallel", "altRecordTerm", "fieldTable", "fieldStream", "dateMask", "databaseMeta");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("schemaName", "getSchemaName");
            put("tableName", "getTableName");
            put("sqlldr", "getSqlldr");
            put("controlFile", "getControlFile");
            put("dataFile", "getDataFile");
            put("logFile", "getLogFile");
            put("badFile", "getBadFile");
            put("discardFile", "getDiscardFile");
            put("commitSize", "getCommitSize");
            put("bindSize", "getBindSize");
            put("readSize", "getReadSize");
            put("maxErrors", "getMaxErrors");
            put("loadMethod", "getLoadMethod");
            put("loadAction", "getLoadAction");
            put("encoding", "getEncoding");
            put("characterSetName", "getCharacterSetName");
            put("directPath", "isDirectPath");
            put("eraseFiles", "isEraseFiles");
            put("dbNameOverride", "getDbNameOverride");
            put("failOnWarning", "isFailOnWarning");
            put("failOnError", "isFailOnError");
            put("parallel", "isParallel");
            put("altRecordTerm", "getAltRecordTerm");
            put("fieldTable", "getFieldTable");
            put("fieldStream", "getFieldStream");
            put("dateMask", "getDateMask");
            put("databaseMeta", "getDatabaseMeta");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("schemaName", "setSchemaName");
            put("tableName", "setTableName");
            put("sqlldr", "setSqlldr");
            put("controlFile", "setControlFile");
            put("dataFile", "setDataFile");
            put("logFile", "setLogFile");
            put("badFile", "setBadFile");
            put("discardFile", "setDiscardFile");
            put("commitSize", "setCommitSize");
            put("bindSize", "setBindSize");
            put("readSize", "setReadSize");
            put("maxErrors", "setMaxErrors");
            put("loadMethod", "setLoadMethod");
            put("loadAction", "setLoadAction");
            put("encoding", "setEncoding");
            put("characterSetName", "setCharacterSetName");
            put("directPath", "setDirectPath");
            put("eraseFiles", "setEraseFiles");
            put("dbNameOverride", "setDbNameOverride");
            put("failOnWarning", "setFailOnWarning");
            put("failOnError", "setFailOnError");
            put("parallel", "setParallel");
            put("altRecordTerm", "setAltRecordTerm");
            put("fieldTable", "setFieldTable");
            put("fieldStream", "setFieldStream");
            put("dateMask", "setDateMask");
            put("databaseMeta", "setDatabaseMeta");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    FieldLoadSaveValidator<String[]> datemaskArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new DateMaskLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldTable", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fieldStream", stringArrayLoadSaveValidator);
    attrValidatorMap.put("dateMask", datemaskArrayLoadSaveValidator);
    attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    // typeValidatorMap.put( int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator( new IntLoadSaveValidator(), 1 ) );
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
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) DatabaseMetaLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator) 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