PropertiesEnvironmentPanel extends PropertiesPanelPresenter { @Min(value=0) private int getRam(@NotNull String environmentId) { boolean isConfigExist = runnerConfigs.containsKey(environmentId) || runnerConfigs.containsKey(URL.encode(environmentId)); if (!isConfigExist) { return DEFAULT.getValue(); } if (runnerConfigs.get(environmentId) != null) { return runnerConfigs.get(environmentId).getRam(); } else { return runnerConfigs.get(URL.encode(environmentId)).getRam(); } } @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 verifySecondConstructorWhenScopeIsProject() throws Exception { reset(appContext, view); when(environment.getScope()).thenReturn(SYSTEM); when(environment.getName()).thenReturn(TEXT); when(environment.getRam()).thenReturn(MB_500.getValue()); when(environment.getPath()).thenReturn(TEXT); when(appContext.getCurrentProject()).thenReturn(currentProject); when(environment.getScope()).thenReturn(PROJECT); presenter = new PropertiesEnvironmentPanel(view, dtoFactory, editorProvider, fileTypeRegistry, dockerFileFactory, projectService, eventBus, appContext, chooseRunnerAction, dialogFactory, locale, projectEnvironmentsAction, notificationManager, unmarshallerFactory, asyncCallbackBuilder, asyncArrayCallbackBuilder, voidAsyncCallbackBuilder, asyncDescriptorCallbackBuilder, templatesContainer, editorAgent, environment); verify(appContext).getCurrentProject(); buttonSaveCancelDeleteShouldBeDisable(); verify(environment, times(2)).getScope(); verify(view).setEnableNameProperty(true); verify(view).setEnableRamProperty(true); verify(view).setEnableBootProperty(false); verify(view).setEnableShutdownProperty(false); verify(view).setEnableScopeProperty(false); view.setVisibleSaveButton(true); view.setVisibleDeleteButton(true); view.setVisibleCancelButton(true); verify(unmarshallerFactory).newListUnmarshaller(ItemReference.class); verify(asyncArrayCallbackBuilder).success(successCallback.capture()); successCallback.getValue().onSuccess(result); verify(projectService).getChildren(eq(TEXT), asyncRequestCallbackArgCaptor.capture()); verify(currentProject, times(2)).getProjectDescription(); verify(projectDescriptor, times(2)).getRunners(); verify(runnersDescriptor, times(2)).getConfigs(); verify(environment, times(2)).getName(); verify(environment, times(2)).getId(); verify(environment, times(2)).getPath(); verify(editorProvider, times(3)).getEditor(); verify(editor, times(3)).addPropertyListener(any(PropertyListener.class)); verify(editor, times(3)).init(any(DockerFileEditorInput.class)); verify(asyncArrayCallbackBuilder).failure(failureCaptor.capture()); failureCaptor.getValue().onFailure(exception); verify(exception).getMessage(); }