ParameterPushdownFactory implements PushDownFactory { @Override public DataServiceDialog.OptimizationOverlay createOverlay() { return new DataServiceDialog.OptimizationOverlay() { @Override public double getPriority() { return 2; } @Override public void apply( final DataServiceDialog dialog ) throws KettleException { ParameterPushdownController controller = createController( dialog.getModel() ); dialog.applyOverlay( this, XUL_SOURCE ).addEventHandler( controller ); } }; }  @Override String getName(); @Override Class<ParameterPushdown> getType(); @Override ParameterPushdown createPushDown(); @Override DataServiceDialog.OptimizationOverlay createOverlay(); ParameterPushdownModel createModel( final DataServiceModel dialogModel );  }
@Test public void testCreateOverlay() throws Exception { DataServiceDialog.OptimizationOverlay overlay = factory.createOverlay(); assertThat( overlay.getPriority(), greaterThan( 1.0 ) ); PushDownOptimizationMeta meta = new PushDownOptimizationMeta(); PushDownOptimizationMeta extra = new PushDownOptimizationMeta(); meta.setType( factory.createPushDown() ); when( dialog.applyOverlay( overlay, ParameterPushdownFactory.XUL_SOURCE ) ).thenReturn( container ); when( dialog.getModel() ).thenReturn( dialogModel ); when( dialogModel.getPushDownOptimizations( TYPE ) ) .thenReturn( ImmutableList.<PushDownOptimizationMeta>of() ) .thenReturn( ImmutableList.of( meta, extra ) ); overlay.apply( dialog ); verify( dialogModel ).add( metaCaptor.capture() ); overlay.apply( dialog ); verify( dialogModel ).removeAll( ImmutableList.of( extra ) ); verify( container, times( 2 ) ).addEventHandler( ctrlCaptor.capture() ); assertThat( getDelegate( 0 ), sameInstance( metaCaptor.getValue().getType() ) ); assertThat( getDelegate( 1 ), sameInstance( meta.getType() ) ); }