Java Code Examples for org.pentaho.di.trans.Trans#setLog()
The following examples show how to use
org.pentaho.di.trans.Trans#setLog() .
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: MissingPluginTransIT.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Given a transformation having a step which's plugin is missing in current Kettle installation. * When this transformation is executed, then execution should fail. */ @Test public void testForPluginMissingStep() throws Exception { InputStream is = new FileInputStream( new File( this.getClass().getResource( "missing_plugin_trans.ktr" ).getFile() ) ); TransMeta transMeta = new TransMeta( is, null, false, null, null ); Trans trans = new Trans( transMeta ); LogChannelInterface log = mock( LogChannelInterface.class ); trans.setLog( log ); try { trans.prepareExecution( null ); fail(); } catch ( KettleException e ) { verify( log, times( 1 ) ).logError( "Step [JSON Input.0] failed to initialize!" ); } }
Example 2
Source File: BaseParsingTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Initialize step info. Method is final against redefine in descendants. */ @Before public final void beforeCommon() throws Exception { KettleEnvironment.init(); PluginRegistry.addPluginType( CompressionPluginType.getInstance() ); PluginRegistry.init( false ); stepMeta = new StepMeta(); stepMeta.setName( "test" ); trans = new Trans(); trans.setLog( log ); trans.setRunning( true ); transMeta = new TransMeta() { @Override public StepMeta findStep( String name ) { return stepMeta; } }; fs = VFS.getManager(); inPrefix = '/' + this.getClass().getPackage().getName().replace( '.', '/' ) + "/files/"; }
Example 3
Source File: TransExecutorUnitTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test //PDI-16066 public void testExecuteTrans() throws KettleException { String childParam = "childParam"; String childValue = "childValue"; String paramOverwrite = "paramOverwrite"; String parentValue = "parentValue"; meta.getParameters().setVariable( new String[]{ childParam, paramOverwrite } ); meta.getParameters().setInput( new String[]{ null, null } ); meta.getParameters().setField( new String[]{ null, null } ); Trans parent = new Trans(); Mockito.when( executor.getTrans() ).thenReturn( parent ); executor.init( meta, data ); executor.setVariable( paramOverwrite, parentValue ); executor.setVariable( childParam, childValue ); Mockito.when( executor.getLogLevel() ).thenReturn( LogLevel.NOTHING ); parent.setLog( new LogChannel( this ) ); Mockito.doCallRealMethod().when( executor ).createInternalTrans( ); Mockito.when( executor.getData().getExecutorTransMeta().listVariables() ).thenReturn( new String[0] ); Mockito.when( executor.getData().getExecutorTransMeta().listParameters() ).thenReturn( new String[0] /*{parentParam}*/ ); Trans internalTrans = executor.createInternalTrans(); executor.getData().setExecutorTrans( internalTrans ); executor.passParametersToTrans( Arrays.asList( meta.getParameters().getInput() ) ); //When the child parameter does exist in the parent parameters, overwrite the child parameter by the parent parameter. Assert.assertEquals( parentValue, internalTrans.getVariable( paramOverwrite ) ); //All other parent parameters need to get copied into the child parameters (when the 'Inherit all variables from the transformation?' option is checked) Assert.assertEquals( childValue, internalTrans.getVariable( childParam ) ); }
Example 4
Source File: TransExecutorUnitTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test //PDI-16066 public void testExecuteTransWithInputsAndNoFields() throws KettleException { String childParam = "childParam"; String childValue = "childValue"; String inputValue1 = "inputValue1"; String inputValue2 = "inputValue2"; String paramOverwrite = "paramOverwrite"; String parentValue = "parentValue"; meta.getParameters().setVariable( new String[]{ childParam, paramOverwrite } ); meta.getParameters().setInput( new String[]{ inputValue1, inputValue2 } ); meta.getParameters().setField( new String[]{ null, null } ); Trans parent = new Trans(); Mockito.when( executor.getTrans() ).thenReturn( parent ); executor.init( meta, data ); executor.setVariable( paramOverwrite, parentValue ); executor.setVariable( childParam, childValue ); Mockito.when( executor.getLogLevel() ).thenReturn( LogLevel.NOTHING ); parent.setLog( new LogChannel( this ) ); Mockito.doCallRealMethod().when( executor ).createInternalTrans( ); Mockito.when( executor.getData().getExecutorTransMeta().listVariables() ).thenReturn( new String[0] ); Mockito.when( executor.getData().getExecutorTransMeta().listParameters() ).thenReturn( new String[0] /*{parentParam}*/ ); Trans internalTrans = executor.createInternalTrans(); executor.getData().setExecutorTrans( internalTrans ); executor.passParametersToTrans( Arrays.asList( meta.getParameters().getField() ) ); //When the child parameter does exist in the parent parameters, overwrite the child parameter by the parent parameter. Assert.assertEquals( inputValue2, internalTrans.getVariable( paramOverwrite ) ); //All other parent parameters need to get copied into the child parameters (when the 'Inherit all variables from the transformation?' option is checked) Assert.assertEquals( inputValue1, internalTrans.getVariable( childParam ) ); }
Example 5
Source File: ScriptValueAddFunctions_SetVariableScopeTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private Trans createTrans() { Trans trans = new Trans(); trans.setLog( mock( LogChannelInterface.class ) ); trans = spy( trans ); return trans; }
Example 6
Source File: JoinRowsTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private JoinRows getJoinRows() throws Exception { StepMeta stepMeta = new StepMeta(); TransMeta transMeta = new TransMeta(); Trans trans = new Trans( transMeta ); transMeta.clear(); transMeta.addStep( stepMeta ); transMeta.setStep( 0, stepMeta ); stepMeta.setName( "test" ); trans.setLog( mock( LogChannelInterface.class ) ); trans.prepareExecution( null ); trans.startThreads(); return new JoinRows( stepMeta, null, 0, transMeta, trans ); }
Example 7
Source File: MetaInjectTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Before public void before() throws Exception { repository = PowerMockito.mock( Repository.class ); transMeta = PowerMockito.spy( new TransMeta() ); meta = new MetaInjectMeta(); data = new MetaInjectData(); data.transMeta = transMeta; metaInject = StepMockUtil.getStep( MetaInject.class, MetaInjectMeta.class, "MetaInjectTest" ); metaInject = PowerMockito.spy( metaInject ); metaInject.init( meta, data ); metaStore = mock( IMetaStore.class ); metaInject.setMetaStore( metaStore ); doReturn( transMeta ).when( metaInject ).getTransMeta(); TransMeta internalTransMeta = mock( TransMeta.class ); StepMeta stepMeta = mock( StepMeta.class ); trans = new Trans(); trans.setLog( LogChannel.GENERAL ); trans = PowerMockito.spy( trans ); doReturn( trans ).when( metaInject ).getTrans(); doReturn( INJECTOR_STEP_NAME ).when( stepMeta ).getName(); doReturn( Collections.singletonList( stepMeta ) ).when( internalTransMeta ).getUsedSteps(); StepMetaInterface stepMetaInterface = mock( StepMetaInterface.class ); doReturn( stepMetaInterface ).when( stepMeta ).getStepMetaInterface(); metaInjectionInterface = mock( StepMetaInjectionInterface.class ); doReturn( metaInjectionInterface ).when( stepMetaInterface ).getStepMetaInjectionInterface(); doReturn( internalTransMeta ).when( metaInject ).loadTransformationMeta(); }
Example 8
Source File: TransExecutorUnitTest.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Test //PDI-16066 public void testExecuteTransWithFieldsAndNoInput() throws KettleException { String childParam = "childParam"; String childValue = "childValue"; String fieldValue1 = "fieldValue1"; String fieldValue2 = "fieldValue2"; String paramOverwrite = "paramOverwrite"; String parentValue = "parentValue"; meta.getParameters().setVariable( new String[]{ childParam, paramOverwrite } ); meta.getParameters().setInput( new String[]{ null, null } ); meta.getParameters().setField( new String[]{ childParam, paramOverwrite } ); Trans parent = new Trans(); Mockito.when( executor.getTrans() ).thenReturn( parent ); executor.init( meta, data ); executor.setVariable( paramOverwrite, parentValue ); executor.setVariable( childParam, childValue ); RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); Mockito.when( executor.getLogLevel() ).thenReturn( LogLevel.NOTHING ); parent.setLog( new LogChannel( this ) ); Mockito.doCallRealMethod().when( executor ).createInternalTrans( ); Mockito.when( executor.getData().getExecutorTransMeta().listVariables() ).thenReturn( new String[0] ); Mockito.when( executor.getData().getExecutorTransMeta().listParameters() ).thenReturn( new String[0] /*{parentParam}*/ ); executor.getData().setInputRowMeta( inputRowMeta ); Mockito.when( executor.getData().getInputRowMeta().getFieldNames() ).thenReturn( new String[]{"childParam", "paramOverwrite"} ); Trans internalTrans = executor.createInternalTrans(); executor.getData().setExecutorTrans( internalTrans ); executor.passParametersToTrans( Arrays.asList( new String[]{ fieldValue1, fieldValue2 } ) ); //When the child parameter does exist in the parent parameters, overwrite the child parameter by the parent parameter. Assert.assertEquals( fieldValue2, internalTrans.getVariable( paramOverwrite ) ); //All other parent parameters need to get copied into the child parameters (when the 'Inherit all variables from the transformation?' option is checked) Assert.assertEquals( fieldValue1, internalTrans.getVariable( childParam ) ); }