ParameterGeneration extends StepOptimization { @Override public OptimizationImpactInfo preview( DataServiceExecutor executor, StepInterface stepInterface ) { ParameterGenerationService service = serviceProvider.getService( stepInterface.getStepMeta() ); Condition pushDownCondition = getPushDownCondition( executor.getSql() ); return service.preview( pushDownCondition, this, stepInterface ); } ParameterGeneration( ParameterGenerationFactory serviceProvider ); String getParameterName(); void setParameterName( String parameterName ); List<SourceTargetFields> getFieldMappings(); SourceTargetFields createFieldMapping(); SourceTargetFields createFieldMapping( String source, String target ); SourceTargetFields removeFieldMapping( SourceTargetFields mapping ); @Override void init( TransMeta transMeta, DataServiceMeta dataService, PushDownOptimizationMeta optMeta ); @Override boolean activate( DataServiceExecutor executor, StepInterface stepInterface ); @Override OptimizationImpactInfo preview( DataServiceExecutor executor, StepInterface stepInterface ); @Override String toString(); static final String PUSH_DOWN_FIELD_MAPPINGS; static final String PUSH_DOWN_PARAMETER_NAME; static final String TYPE_NAME; }
@Test public void testPreview() throws KettleValueException, PushDownOptimizationException { Condition condition = newCondition( "A_src", "A_value" ); SQL query = mockSql( condition ); when( executor.getSql() ).thenReturn( query ); OptimizationImpactInfo optImpact = mock( OptimizationImpactInfo.class ); when( service.preview( any( Condition.class ), same( paramGen ), same( stepInterface ) ) ).thenReturn( optImpact ); assertEquals( optImpact, paramGen.preview( executor, stepInterface ) ); ArgumentCaptor<Condition> pushDownCaptor = ArgumentCaptor.forClass( Condition.class ); verify( service ).preview( pushDownCaptor.capture(), same( paramGen ), same( stepInterface ) ); Condition verify = pushDownCaptor.getValue(); assertEquals( "A_tgt", verify.getLeftValuename() ); assertEquals( "A_value", verify.getRightExactString() ); }