@Test public void testComplete() { 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(); 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 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 );