PropertiesEnvironmentPanel extends PropertiesPanelPresenter { @Override public void onCancelButtonClicked() { view.incorrectName(false); isParameterChanged = false; Scope scope = environment.getScope(); view.setEnableSaveButton(false); view.setEnableCancelButton(false); view.setEnableDeleteButton(PROJECT.equals(scope)); if (editor instanceof UndoableEditor) { HandlesUndoRedo undoRedo = ((UndoableEditor)editor).getUndoRedo(); while (editor.isDirty() && undoRedo.undoable()) { undoOperations++; undoRedo.undo(); } } environment.setRam(currentRam); view.setName(environment.getName()); view.selectMemory(RAM.detect(currentRam)); view.selectScope(environment.getScope()); } @AssistedInject  PropertiesEnvironmentPanel(final PropertiesPanelView view,
                                      DtoFactory dtoFactory,
                                      @Named("DefaultEditorProvider") EditorProvider editorProvider,
                                      @NotNull final FileTypeRegistry fileTypeRegistry,
                                      final DockerFileFactory dockerFileFactory,
                                      final ProjectServiceClient projectService,
                                      EventBus eventBus,
                                      AppContext appContext,
                                      ChooseRunnerAction chooseRunnerAction,
                                      DialogFactory dialogFactory,
                                      RunnerLocalizationConstant locale,
                                      GetProjectEnvironmentsAction projectEnvironmentsAction,
                                      NotificationManager notificationManager,
                                      DtoUnmarshallerFactory unmarshallerFactory,
                                      AsyncCallbackBuilder<ItemReference> asyncCallbackBuilder,
                                      AsyncCallbackBuilder<List<ItemReference>> asyncArrayCallbackBuilder,
                                      AsyncCallbackBuilder<Void> voidAsyncCallbackBuilder,
                                      AsyncCallbackBuilder<ProjectDescriptor> asyncDescriptorCallbackBuilder,
                                      TemplatesContainer templatesContainer,
                                      EditorAgent editorAgent,
                                      @Assisted @NotNull final Environment environment); @Override void onCopyButtonClicked(); @Override void onConfigurationChanged(); @Override void onSaveButtonClicked(); @Override void onDeleteButtonClicked(); @Override void onCancelButtonClicked(); @Override void update(@NotNull Environment environment); @Override void onSwitcherChanged(boolean isOn); @Override void addListener(@NotNull RemovePanelListener listener); static final String ENVIRONMENT_ID_PREFIX; }
@Test public void changesShouldBeCancelWhenScopeIsSystem() { reset(view); presenter.onCancelButtonClicked(); verify(view).setEnableSaveButton(false); verify(view).setEnableCancelButton(false); verify(view).setEnableDeleteButton(false); verify(view).incorrectName(false); verify(environment).getId(); verify(environment).setRam(MB_1000.getValue()); verify(view).setName(TEXT); verify(view).selectMemory(MB_1000); verify(environment, times(3)).getScope(); verify(view).selectScope(SYSTEM); }
@Test public void changesShouldBeCancelWhenScopeIsProject() { when(environment.getScope()).thenReturn(PROJECT); reset(view); presenter.onCancelButtonClicked(); verify(view).setEnableSaveButton(false); verify(view).setEnableCancelButton(false); verify(view).setEnableDeleteButton(true); verify(view).incorrectName(false); verify(environment).getName(); verify(environment).getId(); verify(environment).setRam(MB_1000.getValue()); verify(view).setName(TEXT); verify(view).selectMemory(MB_1000); verify(environment, times(3)).getScope(); verify(view).selectScope(PROJECT); }