PropertiesEnvironmentPanel extends PropertiesPanelPresenter { @Override public void update(@NotNull Environment environment) { view.setEnableCancelButton(isParameterChanged); view.setEnableSaveButton(isParameterChanged); Scope scope = environment.getScope(); view.setEnableDeleteButton(PROJECT.equals(scope)); String environmentName = environment.getName(); String environmentId = environment.getId(); if (!EnvironmentIdValidator.isValid(environmentId)) { environmentId = URL.encode(environmentId); } boolean isConfigExist = runnerConfigs.containsKey(environmentId); RAM ram = RAM.detect(isConfigExist && !isParameterChanged ? getRam(environmentId) : environment.getRam()); if (DEFAULT.getValue() != currentRam && DEFAULT.equals(ram)) { view.addRamValue(currentRam); view.selectMemory(currentRam); this.environment.setRam(currentRam); } else { this.environment.setRam(ram.getValue()); view.selectMemory(ram); } view.selectShutdown(getTimeout()); view.setName(environmentName); String type = getType(environment); view.setType(type); view.selectScope(scope); String defaultRunner = currentProject.getRunner(); view.changeSwitcherState(environmentId.equals(defaultRunner)); } @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 environmentShouldBeUpdatedWhenRunnerConfigExist() throws Exception { reset(view); when(environment.getScope()).thenReturn(SYSTEM); when(environment.getId()).thenReturn(TEXT); when(currentProject.getRunner()).thenReturn(TEXT2); runnerConfigs.put(TEXT, runnerConfiguration); presenter.update(environment); verifyUpdateEnvironment(); verify(view).changeSwitcherState(false); }