ParameterGenerationController extends AbstractController { public void runAutoGenerate() throws XulException { DataServiceModel dialogModel = model.getDialogModel(); try { AutoOptimizationService autoOptimizationService = factory.createAutoOptimizationService(); Collection<PushDownOptimizationMeta> found = autoOptimizationService.apply( dialogModel.getDataService() ); if ( dialogModel.addAll( found ) ) { model.updateParameterMap(); } info( getString( PKG, "ParameterGenerationController.AutoGen.Title" ), getString( PKG, "ParameterGenerationController.AutoGen.Message", found.size() ) ); } catch ( Exception e ) { String message = getString( PKG, "ParameterGenerationController.AutoGen.Error" ); getLogChannel().logError( message, e ); error( getString( PKG, "ParameterGenerationController.AutoGen.Title" ), message ); } } ParameterGenerationController( ParameterGenerationFactory factory, ParameterGenerationModel model ); void initBindings( List<String> supportedSteps ); void runAutoGenerate(); void addParameter(); void editParameter(); void removeParameter();  }
@Test public void testRunAutoGenerate() throws Exception { DataServiceModel dataServiceModel = mock( DataServiceModel.class ); when( model.getDialogModel() ).thenReturn( dataServiceModel ); AutoParameterGenerationService parameterGenerationService = mock( AutoParameterGenerationService.class ); when( factory.createAutoOptimizationService() ).thenReturn( parameterGenerationService ); DataServiceMeta dataServiceMeta = mock( DataServiceMeta.class ); when( dataServiceModel.getDataService() ).thenReturn( dataServiceMeta ); List<PushDownOptimizationMeta> generatedOptimizations = ImmutableList.of( mock( PushDownOptimizationMeta.class ) ); when( parameterGenerationService.apply( dataServiceMeta ) ).thenReturn( generatedOptimizations ); when( dataServiceModel.addAll( generatedOptimizations ) ).thenReturn( true ); controller.runAutoGenerate(); verify( dataServiceModel ).addAll( generatedOptimizations ); verify( model ).updateParameterMap(); verify( messageBox ).open(); }