### Question:
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();  }### Answer:
@Test public void testSave() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveSuccessMessage() ).thenReturn( "SUCCESS" ); presenter.save(); verify( notification ).fire( new NotificationEvent( "SUCCESS", NotificationEvent.NotificationType.SUCCESS ) ); verify( view ).disableActions(); verify( processConfigPresenter ).buildProcessConfig(); final ArgumentCaptor<ProcessConfig> processConfigCaptor = ArgumentCaptor.forClass( ProcessConfig.class ); verify( specManagementService ).updateContainerConfig( eq( templateKey ), eq( containerKey ), eq( Capability.PROCESS ), processConfigCaptor.capture() ); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfigCaptor.getValue() ); }
@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 ); }