@Test public void testComplete() { ServerTemplate serverTemplate = new ServerTemplate("template-name", "template-name"); serverTemplate.setMode(KieServerMode.DEVELOPMENT); serverTemplate.setCapabilities(singletonList(Capability.PROCESS.toString())); when( newTemplatePresenter.isProcessCapabilityChecked() ).thenReturn( true ); when( newContainerFormPresenter.isEmpty() ).thenReturn( true ); when( newContainerFormPresenter.isEmpty() ).thenReturn( true ); when( newTemplatePresenter.getTemplateName() ).thenReturn( "template-name" ); final String successMessage = "SUCCESS"; when( newTemplatePresenterView.getNewServerTemplateWizardSaveSuccess() ).thenReturn( successMessage ); newServerTemplateWizard.complete(); ArgumentCaptor<ServerTemplate> serverTemplateCapture = ArgumentCaptor.forClass(ServerTemplate.class); verify(specManagementService).saveServerTemplate(serverTemplateCapture.capture()); assertEquals(KieServerMode.DEVELOPMENT, serverTemplateCapture.getValue().getMode()); verify( notification ).fire( new NotificationEvent( successMessage, NotificationEvent.NotificationType.SUCCESS ) ); verifyClear(); verify( serverTemplateListRefreshEvent ).fire( new ServerTemplateListRefresh( "template-name" ) ); doThrow( new RuntimeException() ).when( specManagementService ).saveServerTemplate( any( ServerTemplate.class ) ); final String errorMessage = "ERROR"; when( newTemplatePresenterView.getNewServerTemplateWizardSaveError() ).thenReturn( errorMessage ); newServerTemplateWizard.complete(); verify( notification ).fire( new NotificationEvent( errorMessage, NotificationEvent.NotificationType.ERROR ) ); verify( newServerTemplateWizard ).pageSelected( 0 ); verify( newServerTemplateWizard ).start(); verify( newContainerFormPresenter ).initialise(); }
@Override public void complete() { final ServerTemplate newServerTemplate = buildServerTemplate(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void o ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS ) ); clear(); NewServerTemplateWizard.super.complete(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( newServerTemplate.getId() ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR ) ); NewServerTemplateWizard.this.pageSelected( 0 ); NewServerTemplateWizard.this.start(); return false; } } ).saveServerTemplate( newServerTemplate ); }
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void complete() { final ServerTemplate newServerTemplate = buildServerTemplate(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void o ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS ) ); clear(); NewServerTemplateWizard.super.complete(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( newServerTemplate.getId() ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR ) ); NewServerTemplateWizard.this.pageSelected( 0 ); NewServerTemplateWizard.this.start(); return false; } } ).saveServerTemplate( newServerTemplate ); } }
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void complete() { final ServerTemplate newServerTemplate = buildServerTemplate(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void o ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS ) ); clear(); NewServerTemplateWizard.super.complete(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( newServerTemplate.getId() ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR ) ); NewServerTemplateWizard.this.pageSelected( 0 ); NewServerTemplateWizard.this.start(); return false; } } ).saveServerTemplate( newServerTemplate ); } NewServerTemplateWizard(); @Inject  NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
                                    final NewContainerFormPresenter newContainerFormPresenter,
                                    final ProcessConfigPagePresenter processConfigPagePresenter,
                                    final Caller<SpecManagementService> specManagementService,
                                    final Event<NotificationEvent> notification,
                                    final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); }
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void complete() { final ServerTemplate newServerTemplate = buildServerTemplate(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void o ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS ) ); clear(); NewServerTemplateWizard.super.complete(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( newServerTemplate.getId() ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR ) ); NewServerTemplateWizard.this.pageSelected( 0 ); NewServerTemplateWizard.this.start(); return false; } } ).saveServerTemplate( newServerTemplate ); } NewServerTemplateWizard(); @Inject  NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
                                    final NewContainerFormPresenter newContainerFormPresenter,
                                    final ProcessConfigPagePresenter processConfigPagePresenter,
                                    final Caller<SpecManagementService> specManagementService,
                                    final Event<NotificationEvent> notification,
                                    final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void complete() { final ServerTemplate newServerTemplate = buildServerTemplate(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void o ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS ) ); clear(); NewServerTemplateWizard.super.complete(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( newServerTemplate.getId() ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR ) ); NewServerTemplateWizard.this.pageSelected( 0 ); NewServerTemplateWizard.this.start(); return false; } } ).saveServerTemplate( newServerTemplate ); } NewServerTemplateWizard(); @Inject  NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
                                    final NewContainerFormPresenter newContainerFormPresenter,
                                    final ProcessConfigPagePresenter processConfigPagePresenter,
                                    final Caller<SpecManagementService> specManagementService,
                                    final Event<NotificationEvent> notification,
                                    final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete();  }