PropertiesEnvironmentPanel extends PropertiesPanelPresenter { @Override public void onCopyButtonClicked() { List<Environment> projectEnvironments = templatesContainer.getProjectEnvironments(); final String fileName = NameGenerator.generateCopy(environment.getName(), projectEnvironments); String path = projectDescriptor.getPath() + ROOT_FOLDER + fileName; AsyncRequestCallback<ItemReference> callback = asyncCallbackBuilder.unmarshaller(ItemReference.class) .success(new SuccessCallback<ItemReference>() { @Override public void onSuccess(ItemReference result) { getEditorContent(fileName); } }) .failure(new FailureCallback() { @Override public void onFailure(@NotNull Throwable reason) { notificationManager.showError(reason.getMessage()); } }) .build(); projectService.createFolder(path, callback); } @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 copyButtonShouldBeClickedAndButFileContentWasReturnedFailed2() { when(editorProvider.getEditor()).thenReturn(editor); when(file.isReadOnly()).thenReturn(true); presenter.onCopyButtonClicked(); verify(currentProject).getProjectDescription(); verify(projectDescriptor).getPath(); verify(asyncCallbackBuilder).unmarshaller(ItemReference.class); verify(asyncCallbackBuilder).failure(failureCallbackArgCaptor.capture()); failureCallbackArgCaptor.getValue().onFailure(exception); verify(exception).getMessage(); verify(projectService).createFolder(anyString(), eq(asyncRequestCallback)); }