PropertiesEnvironmentPanel extends PropertiesPanelPresenter { @Override public void onDeleteButtonClicked() { if (PROJECT.equals(environment.getScope())) { showDialog(); } } @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 deletedButtonShouldBeClickedAndScopeIsSystem() { presenter.onDeleteButtonClicked(); verifyNoMoreInteractions(dialogFactory); }
@Test public void deletedButtonShouldBeClickedAndScopeIsProjectAndDialogShouldBeShownSuccess() throws Exception { ArgumentCaptor<ConfirmCallback> argumentCaptor = ArgumentCaptor.forClass(ConfirmCallback.class); when(environment.getScope()).thenReturn(PROJECT); presenter.onDeleteButtonClicked(); verify(dialogFactory).createConfirmDialog(eq(TEXT), eq(TEXT), argumentCaptor.capture(), isNull(CancelCallback.class)); verify(confirmDialog).show(); argumentCaptor.getValue().accepted(); verify(projectService).delete(eq(TEXT), requestCallbackArgCaptor.capture()); verify(voidAsyncCallbackBuilder).success(voidArgumentCaptor.capture()); voidArgumentCaptor.getValue().onSuccess(null); verifyUpdateProject(); }
@Test public void deletedButtonShouldBeClickedAndScopeIsProjectAndDialogShouldBeShownSuccessButDeletionSelectedEnvironmentFailed() throws Exception { ArgumentCaptor<ConfirmCallback> argumentCaptor = ArgumentCaptor.forClass(ConfirmCallback.class); when(environment.getScope()).thenReturn(PROJECT); when(exception.getMessage()).thenReturn(TEXT); presenter.onDeleteButtonClicked(); verify(dialogFactory).createConfirmDialog(eq(TEXT), eq(TEXT), argumentCaptor.capture(), isNull(CancelCallback.class)); verify(confirmDialog).show(); argumentCaptor.getValue().accepted(); verify(voidAsyncCallbackBuilder).success(voidArgumentCaptor.capture()); voidArgumentCaptor.getValue().onSuccess(null); verifyUpdateProject(); verify(projectService).delete(TEXT, voidAsyncRequestCallback); verify(voidAsyncCallbackBuilder).failure(failureCallbackArgCaptor.capture()); failureCallbackArgCaptor.getValue().onFailure(exception); verify(exception).getMessage(); verify(notificationManager).showError(TEXT); }
@Test public void stubShouldBeShownWhenDeleteDefaultRunner() { when(environment.getScope()).thenReturn(PROJECT); when(currentProject.getRunner()).thenReturn(TEXT); when(environment.getId()).thenReturn(TEXT); ArgumentCaptor<ConfirmCallback> argumentCaptor = ArgumentCaptor.forClass(ConfirmCallback.class); presenter.onDeleteButtonClicked(); verify(dialogFactory).createConfirmDialog(eq(TEXT), eq(TEXT), argumentCaptor.capture(), isNull(CancelCallback.class)); verify(confirmDialog).show(); argumentCaptor.getValue().accepted(); verify(voidAsyncCallbackBuilder).success(voidArgumentCaptor.capture()); voidArgumentCaptor.getValue().onSuccess(null); verify(templatesContainer).setDefaultEnvironment(null); verify(chooseRunnerAction).setEmptyDefaultRunner(); }