ParameterPushdown implements PushDownType { @Override public void init( TransMeta transMeta, DataServiceMeta dataService, PushDownOptimizationMeta optMeta ) { optMeta.setStepName( dataService.getStepname() ); for ( Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) { Definition definition = iterator.next(); if ( definition.isValid() ) { try { transMeta.addParameterDefinition( definition.getParameter(), "", "Data Service Field Parameter" ); } catch ( DuplicateParamException e ) { } } else { iterator.remove(); } } transMeta.activateParameters(); }  List<Definition> getDefinitions(); Definition createDefinition(); @Override void init( TransMeta transMeta, DataServiceMeta dataService, PushDownOptimizationMeta optMeta ); @Override ListenableFuture<Boolean> activate( DataServiceExecutor executor, PushDownOptimizationMeta meta ); @Override OptimizationImpactInfo preview( DataServiceExecutor executor, PushDownOptimizationMeta meta ); static final String DEFINITIONS_LIST_ATTRIBUTE; static final String PARAMETER_ATTRIBUTE; static final String FIELD_NAME_ATTRIBUTE; static final String FORMAT_ATTRIBUTE; static final String DEFAULT_FORMAT; static final String PARAMETER_PREFIX; }
@Test public void testInit() throws Exception { List<ParameterPushdown.Definition> orig = ImmutableList.copyOf( parameterPushdown.getDefinitions() ); parameterPushdown.createDefinition(); parameterPushdown.createDefinition().setFieldName( "field only" ); parameterPushdown.createDefinition().setParameter( "param only" ); assertThat( parameterPushdown.getDefinitions(), hasSize( 6 ) ); parameterPushdown.init( transMeta, dataService, optimizationMeta ); assertThat( optimizationMeta.getStepName(), is( "OUTPUT" ) ); assertThat( parameterPushdown.getDefinitions(), equalTo( orig ) ); ArgumentCaptor<String> paramCaptor = ArgumentCaptor.forClass( String.class ); verify( transMeta, times( 3 ) ).addParameterDefinition( paramCaptor.capture(), eq( "" ), anyString() ); assertThat( paramCaptor.getAllValues(), contains( "ARTIST_FIELD", "ALBUM_FIELD", "LIVE_FIELD" ) ); verify( transMeta ).activateParameters(); }