@Test public void testSaveError() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveErrorMessage() ).thenReturn( "ERROR" ); doThrow( new RuntimeException() ).when( specManagementService ).updateContainerConfig( anyString(), anyString(), any( Capability.class ), any( ContainerConfig.class ) ); presenter.save(); verify( notification ).fire( new NotificationEvent( "ERROR", NotificationEvent.NotificationType.ERROR ) ); verify( view ).disableActions(); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfig ); }
public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); }
ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } }
ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject  ContainerProcessConfigPresenter( final View view,
                                            final ProcessConfigPresenter processConfigPresenter,
                                            final Caller<SpecManagementService> specManagementService,
                                            final Event<NotificationEvent> notification ); }
ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject  ContainerProcessConfigPresenter( final View view,
                                            final ProcessConfigPresenter processConfigPresenter,
                                            final Caller<SpecManagementService> specManagementService,
                                            final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
                       final ProcessConfig processConfig ); void disable(); void save(); void cancel(); }
ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject  ContainerProcessConfigPresenter( final View view,
                                            final ProcessConfigPresenter processConfigPresenter,
                                            final Caller<SpecManagementService> specManagementService,
                                            final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
                       final ProcessConfig processConfig ); void disable(); void save(); void cancel();  }