ParameterGenerationController extends AbstractController { public void removeParameter() throws XulException { PushDownOptimizationMeta meta = checkNotNull( model.getSelectedOptimization() ); String parameterName = ( (ParameterGeneration) meta.getType() ).getParameterName(); XulMessageBox messageBox = createMessageBox(); messageBox.setTitle( getString( PKG, "ParameterGenerationController.Delete.Title" ) ); messageBox.setMessage( getString( PKG, "ParameterGenerationController.Delete.Message", parameterName ) ); messageBox.setIcon( SWT.ICON_QUESTION ); messageBox.setButtons( new Object[] { SWT.YES, SWT.NO } ); if ( messageBox.open() == SWT.YES ) { model.setSelectedParameter( null ); model.remove( meta ); } } ParameterGenerationController( ParameterGenerationFactory factory, ParameterGenerationModel model ); void initBindings( List<String> supportedSteps ); void runAutoGenerate(); void addParameter(); void editParameter(); void removeParameter();  }
@Test public void testRemoveParameter() throws Exception { PushDownOptimizationMeta meta = new PushDownOptimizationMeta(); ParameterGeneration parameterGeneration = new ParameterGeneration( factory ); parameterGeneration.setParameterName( "parameterName" ); setSelected( meta, parameterGeneration ); when( messageBox.open() ).thenReturn( SWT.NO ); controller.removeParameter(); verify( model, never() ).remove( any( PushDownOptimizationMeta.class ) ); when( messageBox.open() ).thenReturn( SWT.YES ); controller.removeParameter(); verify( model ).setSelectedParameter( null ); verify( model ).remove( meta ); verify( messageBox, times( 2 ) ).setIcon( SWT.ICON_QUESTION ); }