@Test public void testProcessRow() throws Exception { SystemDataData systemDataData = new SystemDataData(); SystemDataMeta systemDataMeta = new SystemDataMeta(); systemDataMeta.allocate( 2 ); String[] names = systemDataMeta.getFieldName(); SystemDataTypes[] types = systemDataMeta.getFieldType(); names[0] = "hostname"; names[1] = "hostname_real"; types[0] = SystemDataMeta.getType( SystemDataMeta.getTypeDesc( SystemDataTypes.TYPE_SYSTEM_INFO_HOSTNAME ) ); types[1] = SystemDataMeta.getType( SystemDataMeta.getTypeDesc( SystemDataTypes.TYPE_SYSTEM_INFO_HOSTNAME_REAL ) ); SystemDataHandler systemData = new SystemDataHandler( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); Object[] expectedRow = new Object[] { Const.getHostname(), Const.getHostnameReal() }; RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); when( inputRowMeta.clone() ).thenReturn( inputRowMeta ); when( inputRowMeta.size() ).thenReturn( 2 ); systemDataData.outputRowMeta = inputRowMeta; systemData.init( systemDataMeta, systemDataData ); assertFalse( systemData.processRow( systemDataMeta, systemDataData ) ); Object[] out = systemData.getOutputRow(); assertArrayEquals( expectedRow, out ); }
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { Object[] row; if ( data.readsRows ) { row = getRow(); if ( row == null ) { setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } else { row = new Object[] {}; incrementLinesRead(); if ( first ) { first = false; data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } RowMetaInterface imeta = getInputRowMeta(); if ( imeta == null ) { imeta = new RowMeta(); this.setInputRowMeta( imeta ); } row = getSystemData( imeta, row ); if ( log.isRowLevel() ) { logRowlevel( "System info returned: " + data.outputRowMeta.getString( row ) ); } putRow( data.outputRowMeta, row ); if ( !data.readsRows ) { setOutputDone(); return false; } return true; }
SystemData extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { Object[] row; if ( data.readsRows ) { row = getRow(); if ( row == null ) { setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } else { row = new Object[] {}; incrementLinesRead(); if ( first ) { first = false; data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } RowMetaInterface imeta = getInputRowMeta(); if ( imeta == null ) { imeta = new RowMeta(); this.setInputRowMeta( imeta ); } row = getSystemData( imeta, row ); if ( log.isRowLevel() ) { logRowlevel( "System info returned: " + data.outputRowMeta.getString( row ) ); } putRow( data.outputRowMeta, row ); if ( !data.readsRows ) { setOutputDone(); return false; } return true; } }
SystemData extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { Object[] row; if ( data.readsRows ) { row = getRow(); if ( row == null ) { setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } else { row = new Object[] {}; incrementLinesRead(); if ( first ) { first = false; data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } RowMetaInterface imeta = getInputRowMeta(); if ( imeta == null ) { imeta = new RowMeta(); this.setInputRowMeta( imeta ); } row = getSystemData( imeta, row ); if ( log.isRowLevel() ) { logRowlevel( "System info returned: " + data.outputRowMeta.getString( row ) ); } putRow( data.outputRowMeta, row ); if ( !data.readsRows ) { setOutputDone(); return false; } return true; } SystemData( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); }
SystemData extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { Object[] row; if ( data.readsRows ) { row = getRow(); if ( row == null ) { setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } else { row = new Object[] {}; incrementLinesRead(); if ( first ) { first = false; data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } RowMetaInterface imeta = getInputRowMeta(); if ( imeta == null ) { imeta = new RowMeta(); this.setInputRowMeta( imeta ); } row = getSystemData( imeta, row ); if ( log.isRowLevel() ) { logRowlevel( "System info returned: " + data.outputRowMeta.getString( row ) ); } putRow( data.outputRowMeta, row ); if ( !data.readsRows ) { setOutputDone(); return false; } return true; } SystemData( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
SystemData extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { Object[] row; if ( data.readsRows ) { row = getRow(); if ( row == null ) { setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } else { row = new Object[] {}; incrementLinesRead(); if ( first ) { first = false; data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } RowMetaInterface imeta = getInputRowMeta(); if ( imeta == null ) { imeta = new RowMeta(); this.setInputRowMeta( imeta ); } row = getSystemData( imeta, row ); if ( log.isRowLevel() ) { logRowlevel( "System info returned: " + data.outputRowMeta.getString( row ) ); } putRow( data.outputRowMeta, row ); if ( !data.readsRows ) { setOutputDone(); return false; } return true; } SystemData( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi );  }