@SuppressWarnings( "deprecation" ) private void compatibleGetStepFields( StepMetaInterface stepint, RowMetaInterface row, String name, RowMetaInterface[] inform, StepMeta nextStep, VariableSpace space ) throws KettleStepException { stepint.getFields( row, name, inform, nextStep, space ); }
private StepMetaInterface stepMetaInterfaceWithFields( StepMetaInterface smi, List<String> infoStepnames, List<String> fieldNames ) throws KettleStepException { RowMeta rowMetaWithFields = new RowMeta(); StepIOMeta stepIOMeta = mock( StepIOMeta.class ); when( stepIOMeta.getInfoStepnames() ).thenReturn( infoStepnames.toArray( new String[ 0 ] ) ); fieldNames.stream() .forEach( field -> rowMetaWithFields.addValueMeta( new ValueMetaString( field ) ) ); StepMetaInterface newSmi = spy( smi ); when( newSmi.getStepIOMeta() ).thenReturn( stepIOMeta ); doAnswer( (Answer<Void>) invocationOnMock -> { RowMetaInterface passedRmi = (RowMetaInterface) invocationOnMock.getArguments()[ 0 ]; passedRmi.addRowMeta( rowMetaWithFields ); return null; } ).when( newSmi ) .getFields( any(), any(), any(), any(), any(), any(), any() ); return newSmi; }
@Test public void getThisStepFieldsPassesClonedInfoRowMeta() throws Exception { // given StepMetaInterface smi = mock( StepMetaInterface.class ); StepIOMeta ioMeta = mock( StepIOMeta.class ); when( smi.getStepIOMeta() ).thenReturn( ioMeta ); StepMeta thisStep = mockStepMeta( "thisStep" ); StepMeta nextStep = mockStepMeta( "nextStep" ); when( thisStep.getStepMetaInterface() ).thenReturn( smi ); RowMeta row = new RowMeta(); when( smi.getTableFields() ).thenReturn( row ); // when transMeta.getThisStepFields( thisStep, nextStep, row ); // then verify( smi, never() ).getFields( any(), any(), eq( new RowMetaInterface[] { row } ), any(), any(), any(), any() ); }
.getFields( rowMeta, origin, info, nextStep, space, repository, metaStore ); } catch ( KettleStepException e ) { throw new RuntimeException( e );
@Test public void getThisStepFieldsPassesCloneRowMeta() throws Exception { final String overriddenValue = "overridden"; StepMeta nextStep = mockStepMeta( "nextStep" ); StepMetaInterface smi = mock( StepMetaInterface.class ); StepIOMeta ioMeta = mock( StepIOMeta.class ); when( smi.getStepIOMeta() ).thenReturn( ioMeta ); doAnswer( new Answer<Object>() { @Override public Object answer( InvocationOnMock invocation ) throws Throwable { RowMetaInterface rmi = (RowMetaInterface) invocation.getArguments()[ 0 ]; rmi.clear(); rmi.addValueMeta( new ValueMetaString( overriddenValue ) ); return null; } } ).when( smi ).getFields( any( RowMetaInterface.class ), anyString(), any( RowMetaInterface[].class ), eq( nextStep ), any( VariableSpace.class ), any( Repository.class ), any( IMetaStore.class ) ); StepMeta thisStep = mockStepMeta( "thisStep" ); when( thisStep.getStepMetaInterface() ).thenReturn( smi ); RowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaString( "value" ) ); RowMetaInterface thisStepsFields = transMeta.getThisStepFields( thisStep, nextStep, rowMeta ); assertEquals( 1, thisStepsFields.size() ); assertEquals( overriddenValue, thisStepsFields.getValueMeta( 0 ).getName() ); }
@Test public void testGetFieldsDoesEnvSubstitutionForSubStepName() throws KettleStepException { // https://jira.pentaho.com/browse/BACKLOG-22575 BaseStreamStepMeta meta = new StuffStreamMeta(); meta.setSubStep( "${parameter}" ); when( space.environmentSubstitute( "${parameter}" ) ).thenReturn( "realSubStepName" ); when( subTransStepMeta.getName() ).thenReturn( "realSubStepName" ); meta.mappingMetaRetriever = mappingMetaRetriever; meta.getFields( rowMeta, "origin", null, nextStepMeta, space, repo, null ); verify( space ).environmentSubstitute( "${parameter}" ); verify( subTransMeta ).getPrevStepFields( "realSubStepName" ); verify( stepMetaInterface ) .getFields( rowMeta, "origin", null, nextStepMeta, space, repo, null ); }
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { if ( data.resultFilesList == null || getLinesRead() >= data.resultFilesList.size() ) { setOutputDone(); return false; } ResultFile resultFile = data.resultFilesList.get( (int) getLinesRead() ); RowMetaAndData r = resultFile.getRow(); if ( first ) { first = false; data.outputRowMeta = new RowMeta(); smi.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } incrementLinesRead(); putRow( data.outputRowMeta, r.getData() ); // copy row to possible alternate // rowset(s). if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "FilesFromResult.Log.LineNumber" ) + getLinesRead() ); } return true; }
compatibleGetStepFields( stepint, row, name, clonedInfo, nextStep, this ); if ( !isSomethingDifferentInRow( before, row ) ) { stepint.getFields( before, name, clonedInfo, nextStep, this, repository, metaStore );
inputStepMeta.getFields( injectorRowMeta, null, null, null, null );