@Test public void processRow_NullsArePutIntoDefaultWhenNotSpecified() throws Exception { SwitchCaseCustom step = new SwitchCaseCustom( mockHelper ); step.meta.loadXML( loadStepXmlMetadata( "SwitchCaseTest_PDI-12671.xml" ), Collections.<DatabaseMeta>emptyList(), mock( IMetaStore.class ) ); List<RowSet> outputRowSets = new LinkedList<RowSet>(); for ( SwitchCaseTarget item : step.meta.getCaseTargets() ) { StepMetaInterface smInt = new DummyTransMeta(); item.caseTargetStep = new StepMeta( item.caseTargetStepname, smInt ); RowSet rw = new QueueRowSet(); step.map.put( item.caseTargetStepname, rw ); outputRowSets.add( rw ); } StepMetaInterface smInt = new DummyTransMeta(); StepMeta stepMeta = new StepMeta( step.meta.getDefaultTargetStepname(), smInt ); step.meta.setDefaultTargetStep( stepMeta ); RowSet defaultRowSet = new QueueRowSet(); step.map.put( step.meta.getDefaultTargetStepname(), defaultRowSet ); step.input.add( new Object[] { null } ); step.processRow(); assertEquals( 1, defaultRowSet.size() ); for ( RowSet rowSet : outputRowSets ) { assertEquals( 0, rowSet.size() ); } assertNull( defaultRowSet.getRow()[0] ); }
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 );  }