Java Code Examples for org.pentaho.di.trans.TransMeta#injectVariables()
The following examples show how to use
org.pentaho.di.trans.TransMeta#injectVariables() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CsvInputFileEncodingIT.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Before protected void setUp() throws Exception { TransMeta transMeta = new TransMeta(); transMeta.setName( "csvinput1" ); Map<String, String> vars = new HashMap<String, String>(); vars.put( "${P_ENCODING}", "UTF-8" ); vars.put( "P_ENCODING", "UTF-8" ); transMeta.injectVariables( vars ); StepMeta csvStepMeta = createCsvInputStep( transMeta, PluginRegistry.getInstance(), "\"", false ); // Now execute the transformation... Trans trans = new Trans( transMeta ); csvInput = new CsvInput( csvStepMeta, new CsvInputData(), 1, transMeta, trans ); csvInput.copyVariablesFrom( trans ); csvInpMeta = (CsvInputMeta) csvStepMeta.getStepMetaInterface(); csvInpMeta.setFilename( "temp_file" ); super.setUp(); }
Example 2
Source File: DeleteMetaTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Before public void setUp() { TransMeta transMeta = new TransMeta(); transMeta.setName( "delete1" ); Map<String, String> vars = new HashMap<String, String>(); vars.put( "max.sz", "10" ); transMeta.injectVariables( vars ); dmi = new DeleteMeta(); dd = new DeleteData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String deletePid = plugReg.getPluginId( StepPluginType.class, dmi ); stepMeta = new StepMeta( deletePid, "delete", dmi ); Trans trans = new Trans( transMeta ); transMeta.addStep( stepMeta ); del = new Delete( stepMeta, dd, 1, transMeta, trans ); del.copyVariablesFrom( transMeta ); }
Example 3
Source File: InsertUpdateMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Before public void setUp() { TransMeta transMeta = new TransMeta(); transMeta.setName( "delete1" ); Map<String, String> vars = new HashMap<String, String>(); vars.put( "max.sz", "10" ); transMeta.injectVariables( vars ); umi = new InsertUpdateMeta(); ud = new InsertUpdateData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String deletePid = plugReg.getPluginId( StepPluginType.class, umi ); stepMeta = new StepMeta( deletePid, "delete", umi ); Trans trans = new Trans( transMeta ); transMeta.addStep( stepMeta ); upd = new InsertUpdate( stepMeta, ud, 1, transMeta, trans ); upd.copyVariablesFrom( transMeta ); mockHelper = new StepMockHelper<>( "insertUpdate", InsertUpdateMeta.class, InsertUpdateData.class ); Mockito.when( mockHelper.logChannelInterfaceFactory.create( Mockito.any(), Mockito.any( LoggingObjectInterface.class ) ) ) .thenReturn( mockHelper.logChannelInterface ); Mockito.when( mockHelper.stepMeta.getStepMetaInterface() ).thenReturn( new InsertUpdateMeta() ); }
Example 4
Source File: RowGeneratorUnitTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Before public void setUp() throws KettleException { // add variable to row generator step StepMetaInterface stepMetaInterface = spy( new RowGeneratorMeta() ); ( (RowGeneratorMeta) stepMetaInterface ).setRowLimit( "${ROW_LIMIT}" ); String[] strings = {}; when( ( (RowGeneratorMeta) stepMetaInterface ).getFieldName() ).thenReturn( strings ); StepMeta stepMeta = new StepMeta(); stepMeta.setStepMetaInterface( stepMetaInterface ); stepMeta.setName( "ROW_STEP_META" ); StepDataInterface stepDataInterface = stepMeta.getStepMetaInterface().getStepData(); // add variable to transformation variable space Map<String, String> map = new HashMap<String, String>(); map.put( "ROW_LIMIT", "1440" ); TransMeta transMeta = spy( new TransMeta() ); transMeta.injectVariables( map ); when( transMeta.findStep( anyString() ) ).thenReturn( stepMeta ); Trans trans = spy( new Trans( transMeta, null ) ); when( trans.getSocketRepository() ).thenReturn( null ); when( trans.getLogChannelId() ).thenReturn( "ROW_LIMIT" ); //prepare row generator, substitutes variable by value from transformation variable space rowGenerator = spy( new RowGenerator( stepMeta, stepDataInterface, 0, transMeta, trans ) ); rowGenerator.initializeVariablesFrom( trans ); rowGenerator.init( stepMetaInterface, stepDataInterface ); }
Example 5
Source File: MySQLBulkLoaderTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Before public void setUp() { TransMeta transMeta = new TransMeta(); transMeta.setName( "MysqlBulkLoader" ); Map<String, String> vars = new HashMap<String, String>(); vars.put( "delim", "," ); vars.put( "enclos", "'" ); vars.put( "charset", "UTF8" ); vars.put( "tbl", "sometable" ); vars.put( "schema", "someschema" ); transMeta.injectVariables( vars ); MySQLDatabaseMeta mysql = new MySQLDatabaseMeta(); mysql.setName( "MySQL" ); DatabaseMeta dbMeta = new DatabaseMeta(); dbMeta.setDatabaseInterface( mysql ); dbMeta.setQuoteAllFields( true ); lmeta = new MySQLBulkLoaderMeta(); lmeta.setDelimiter( "${delim}" ); lmeta.setEnclosure( "${enclos}" ); lmeta.setEncoding( "${charset}" ); lmeta.setTableName( "${tbl}" ); lmeta.setSchemaName( "${schema}" ); lmeta.setDatabaseMeta( dbMeta ); ldata = new MySQLBulkLoaderData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String mblPid = plugReg.getPluginId( StepPluginType.class, lmeta ); smeta = new StepMeta( mblPid, "MySqlBulkLoader", lmeta ); Trans trans = new Trans( transMeta ); transMeta.addStep( smeta ); lder = new MySQLBulkLoader( smeta, ldata, 1, transMeta, trans ); lder.copyVariablesFrom( transMeta ); }
Example 6
Source File: UpdateMetaTest.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Before public void setUp() throws KettleException { KettleEnvironment.init(); PluginRegistry.init( false ); TransMeta transMeta = new TransMeta(); transMeta.setName( "delete1" ); Map<String, String> vars = new HashMap<String, String>(); vars.put( "max.sz", "10" ); transMeta.injectVariables( vars ); umi = new UpdateMeta(); ud = new UpdateData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String deletePid = plugReg.getPluginId( StepPluginType.class, umi ); stepMeta = new StepMeta( deletePid, "delete", umi ); Trans trans = new Trans( transMeta ); transMeta.addStep( stepMeta ); mockHelper = new StepMockHelper<>( "Update", UpdateMeta.class, UpdateData.class ); Mockito.when( mockHelper.logChannelInterfaceFactory.create( Mockito.any(), Mockito.any( LoggingObjectInterface.class ) ) ).thenReturn( mockHelper.logChannelInterface ); upd = new Update( stepMeta, ud, 1, transMeta, trans ); upd.copyVariablesFrom( transMeta ); List<String> attributes = Arrays.asList( "schemaName", "tableName", "commitSize", "errorIgnored", "ignoreFlagField", "skipLookup", "useBatchUpdate", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "databaseMeta" ); Map<String, String> getterMap = new HashMap<String, String>() { { put( "schemaName", "getSchemaName" ); put( "tableName", "getTableName" ); put( "commitSize", "getCommitSizeVar" ); put( "errorIgnored", "isErrorIgnored" ); put( "ignoreFlagField", "getIgnoreFlagField" ); put( "skipLookup", "isSkipLookup" ); put( "useBatchUpdate", "useBatchUpdate" ); put( "keyStream", "getKeyStream" ); put( "keyLookup", "getKeyLookup" ); put( "keyCondition", "getKeyCondition" ); put( "keyStream2", "getKeyStream2" ); put( "updateLookup", "getUpdateLookup" ); put( "updateStream", "getUpdateStream" ); put( "databaseMeta", "getDatabaseMeta" ); } }; Map<String, String> setterMap = new HashMap<String, String>() { { put( "schemaName", "setSchemaName" ); put( "tableName", "setTableName" ); put( "commitSize", "setCommitSize" ); put( "errorIgnored", "setErrorIgnored" ); put( "ignoreFlagField", "setIgnoreFlagField" ); put( "skipLookup", "setSkipLookup" ); put( "useBatchUpdate", "setUseBatchUpdate" ); put( "keyStream", "setKeyStream" ); put( "keyLookup", "setKeyLookup" ); put( "keyCondition", "setKeyCondition" ); put( "keyStream2", "setKeyStream2" ); put( "updateLookup", "setUpdateLookup" ); put( "updateStream", "setUpdateStream" ); put( "databaseMeta", "setDatabaseMeta" ); } }; 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( "keyCondition", stringArrayLoadSaveValidator ); attrValidatorMap.put( "keyStream2", stringArrayLoadSaveValidator ); attrValidatorMap.put( "updateLookup", stringArrayLoadSaveValidator ); attrValidatorMap.put( "updateStream", stringArrayLoadSaveValidator ); attrValidatorMap.put( "databaseMeta", new DatabaseMetaLoadSaveValidator() ); Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>(); loadSaveTester = new LoadSaveTester( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this ); }