@Test public void testProcessRow() throws KettleException { SwitchCaseCustom krasavez = new SwitchCaseCustom( mockHelper ); krasavez.first = false; RowSet rowSetOne = new QueueRowSet(); RowSet rowSetTwo = new QueueRowSet(); krasavez.data.outputMap.put( 3, rowSetOne ); krasavez.data.outputMap.put( 3, rowSetTwo ); RowSet rowSetNullOne = new QueueRowSet(); RowSet rowSetNullTwo = new QueueRowSet(); krasavez.data.nullRowSetSet.add( rowSetNullOne ); krasavez.data.nullRowSetSet.add( rowSetNullTwo ); RowSet def = new QueueRowSet(); krasavez.data.defaultRowSetSet.add( def ); krasavez.generateData( 1, 5, 2 ); krasavez.processRow(); assertEquals( "First row set collects 2 rows", 2, rowSetOne.size() ); assertEquals( "Second row set collects 2 rows", 2, rowSetTwo.size() ); assertEquals( "First null row set collects 5 rows", 6, rowSetNullOne.size() ); assertEquals( "Second null row set collects 5 rows", 6, rowSetNullTwo.size() ); assertEquals( "Default row set collects the rest of rows", 8, def.size() ); assertEquals( "First row set contains only 3: ", true, isRowSetContainsValue( rowSetOne, new Object[] { 3 }, new Object[] { } ) ); assertEquals( "Second row set contains only 3: ", true, isRowSetContainsValue( rowSetTwo, new Object[] { 3 }, new Object[] { } ) ); assertEquals( "First null row set contains only null: ", true, isRowSetContainsValue( rowSetNullOne, new Object[] { null }, new Object[] { } ) ); assertEquals( "Second null row set contains only null: ", true, isRowSetContainsValue( rowSetNullTwo, new Object[] { null }, new Object[] { } ) ); assertEquals( "Default row set do not contains null or 3, but other", true, isRowSetContainsValue( def, new Object[] { 1, 2, 4, 5 }, new Object[] { 3, null } ) ); }
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SwitchCaseMeta) smi; data = (SwitchCaseData) sdi; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; createOutputValueMapping(); } Object lookupData = data.valueMeta.convertData( data.inputValueMeta, r[data.fieldIndex] ); Set<RowSet> rowSetSet = ( data.valueMeta.isNull( lookupData ) ) ? data.nullRowSetSet : data.outputMap.get( lookupData ); if ( rowSetSet == null ) { rowSetSet = data.defaultRowSetSet; } for ( RowSet rowSet : rowSetSet ) { putRowTo( data.outputRowMeta, r, rowSet ); } if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "SwitchCase.Log.LineNumber" ) + getLinesRead() ); } } return true; }
SwitchCase extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SwitchCaseMeta) smi; data = (SwitchCaseData) sdi; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; createOutputValueMapping(); } Object lookupData = data.valueMeta.convertData( data.inputValueMeta, r[data.fieldIndex] ); Set<RowSet> rowSetSet = ( data.valueMeta.isNull( lookupData ) ) ? data.nullRowSetSet : data.outputMap.get( lookupData ); if ( rowSetSet == null ) { rowSetSet = data.defaultRowSetSet; } for ( RowSet rowSet : rowSetSet ) { putRowTo( data.outputRowMeta, r, rowSet ); } if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "SwitchCase.Log.LineNumber" ) + getLinesRead() ); } } return true; } }
SwitchCase extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SwitchCaseMeta) smi; data = (SwitchCaseData) sdi; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; createOutputValueMapping(); } Object lookupData = data.valueMeta.convertData( data.inputValueMeta, r[data.fieldIndex] ); Set<RowSet> rowSetSet = ( data.valueMeta.isNull( lookupData ) ) ? data.nullRowSetSet : data.outputMap.get( lookupData ); if ( rowSetSet == null ) { rowSetSet = data.defaultRowSetSet; } for ( RowSet rowSet : rowSetSet ) { putRowTo( data.outputRowMeta, r, rowSet ); } if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "SwitchCase.Log.LineNumber" ) + getLinesRead() ); } } return true; } SwitchCase( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
                     Trans trans ); }
SwitchCase extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SwitchCaseMeta) smi; data = (SwitchCaseData) sdi; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; createOutputValueMapping(); } Object lookupData = data.valueMeta.convertData( data.inputValueMeta, r[data.fieldIndex] ); Set<RowSet> rowSetSet = ( data.valueMeta.isNull( lookupData ) ) ? data.nullRowSetSet : data.outputMap.get( lookupData ); if ( rowSetSet == null ) { rowSetSet = data.defaultRowSetSet; } for ( RowSet rowSet : rowSetSet ) { putRowTo( data.outputRowMeta, r, rowSet ); } if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "SwitchCase.Log.LineNumber" ) + getLinesRead() ); } } return true; } SwitchCase( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
                     Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
SwitchCase extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SwitchCaseMeta) smi; data = (SwitchCaseData) sdi; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; createOutputValueMapping(); } Object lookupData = data.valueMeta.convertData( data.inputValueMeta, r[data.fieldIndex] ); Set<RowSet> rowSetSet = ( data.valueMeta.isNull( lookupData ) ) ? data.nullRowSetSet : data.outputMap.get( lookupData ); if ( rowSetSet == null ) { rowSetSet = data.defaultRowSetSet; } for ( RowSet rowSet : rowSetSet ) { putRowTo( data.outputRowMeta, r, rowSet ); } if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "SwitchCase.Log.LineNumber" ) + getLinesRead() ); } } return true; } SwitchCase( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
                     Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi );  }