StepOptimization implements PushDownType { @Override public OptimizationImpactInfo preview( DataServiceExecutor executor, PushDownOptimizationMeta meta ) { OptimizationImpactInfo info = new OptimizationImpactInfo( meta.getStepName() ); Trans serviceTrans = executor.getServiceTrans(); try { serviceTrans.prepareExecution( null ); info = preview( executor, serviceTrans.findRunThread( meta.getStepName() ) ); for ( StepMetaDataCombi stepMetaDataCombi : serviceTrans.getSteps() ) { stepMetaDataCombi.step.setOutputDone(); stepMetaDataCombi.step.dispose( stepMetaDataCombi.meta, stepMetaDataCombi.data ); stepMetaDataCombi.step.markStop(); } } catch ( Exception e ) { info.setErrorMsg( e ); } return info; }  ListenableFuture<Boolean> activate( final DataServiceExecutor executor,
                                             final PushDownOptimizationMeta meta ); @Override OptimizationImpactInfo preview( DataServiceExecutor executor, PushDownOptimizationMeta meta );  }
@Test public void testPreview() throws Exception { OptimizationImpactInfo impactInfo = new OptimizationImpactInfo( OPTIMIZED_STEP ); doReturn( impactInfo ).when( stepOptimization ).preview( executor, stepInterface ); StepMetaDataCombi stepStruct = new StepMetaDataCombi() { { stepMeta = mock( StepMeta.class ); stepname = OPTIMIZED_STEP; copy = 0; step = stepInterface; meta = mock( StepMetaInterface.class ); data = mock( StepDataInterface.class ); } }; when( serviceTrans.getSteps() ).thenReturn( ImmutableList.of( stepStruct ) ); assertThat( stepOptimization.preview( executor, meta ), sameInstance( impactInfo ) ); final InOrder inOrder = inOrder( serviceTrans, stepInterface, stepOptimization ); inOrder.verify( serviceTrans ).prepareExecution( null ); inOrder.verify( serviceTrans ).findRunThread( OPTIMIZED_STEP ); inOrder.verify( stepOptimization ).preview( executor, stepInterface ); inOrder.verify( stepInterface ).setOutputDone(); inOrder.verify( stepInterface ).dispose( stepStruct.meta, stepStruct.data ); inOrder.verify( stepInterface ).markStop(); }