Search in sources :

Example 1 with ConfirmDialog

use of org.eclipse.che.ide.api.dialogs.ConfirmDialog in project che by eclipse.

the class SshKeyManagerPresenterTest method testOnDeleteClickedWhenDeleteKeyCanceled.

@Test
public void testOnDeleteClickedWhenDeleteKeyCanceled() {
    SafeHtml safeHtml = mock(SafeHtml.class);
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    when(constant.deleteSshKeyQuestion(anyString())).thenReturn(safeHtml);
    when(safeHtml.asString()).thenReturn("");
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), (ConfirmCallback) anyObject(), (CancelCallback) anyObject())).thenReturn(confirmDialog);
    presenter.onDeleteClicked(sshPairDto);
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), (ConfirmCallback) anyObject(), cancelCallbackCaptor.capture());
    CancelCallback cancelCallback = cancelCallbackCaptor.getValue();
    cancelCallback.cancelled();
    verify(confirmDialog).show();
    verify(service, never()).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), anyString());
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CancelCallback(org.eclipse.che.ide.api.dialogs.CancelCallback) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Example 2 with ConfirmDialog

use of org.eclipse.che.ide.api.dialogs.ConfirmDialog in project che by eclipse.

the class SshKeyManagerPresenterTest method testFailedRefreshKeysAfterSuccessfulDeleteKey.

@Test
public void testFailedRefreshKeysAfterSuccessfulDeleteKey() throws OperationException {
    when(sshPairDto.getService()).thenReturn(SshKeyManagerPresenter.VCS_SSH_SERVICE);
    when(sshPairDto.getName()).thenReturn(GITHUB_HOST);
    SafeHtml safeHtml = mock(SafeHtml.class);
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    List<SshPairDto> sshPairDtoArray = new ArrayList<>();
    when(constant.deleteSshKeyQuestion(anyString())).thenReturn(safeHtml);
    when(safeHtml.asString()).thenReturn("");
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), (ConfirmCallback) anyObject(), (CancelCallback) anyObject())).thenReturn(confirmDialog);
    presenter.onDeleteClicked(sshPairDto);
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), confirmCallbackCaptor.capture(), (CancelCallback) anyObject());
    ConfirmCallback confirmCallback = confirmCallbackCaptor.getValue();
    confirmCallback.accepted();
    verify(voidPromise).then(operationVoidCapture.capture());
    operationVoidCapture.getValue().apply(null);
    verify(sshPairDTOsPromise).catchError(operationErrorCapture.capture());
    operationErrorCapture.getValue().apply(JsPromiseError.create(""));
    verify(confirmDialog).show();
    verify(service).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), eq(GITHUB_HOST));
    verify(service).getPairs(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE));
    verify(view, never()).setPairs(eq(sshPairDtoArray));
    verify(notificationManager).notify(anyString(), any(StatusNotification.Status.class), (DisplayMode) anyObject());
}
Also used : SshPairDto(org.eclipse.che.api.ssh.shared.dto.SshPairDto) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Example 3 with ConfirmDialog

use of org.eclipse.che.ide.api.dialogs.ConfirmDialog in project che by eclipse.

the class JavaRefactoringRenameTest method renameRefactoringShouldBeFailedByError.

@Test
public void renameRefactoringShouldBeFailedByError() throws OperationException {
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    when(result.getSeverity()).thenReturn(ERROR);
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), anyString(), anyString(), Matchers.<ConfirmCallback>anyObject(), Matchers.<CancelCallback>anyObject())).thenReturn(confirmDialog);
    refactoringRename.refactor(textEditor);
    verify(refactoringServiceClient).createRenameRefactoring(createRenameRefactoringDto);
    verify(createRenamePromise).then(renameRefCaptor.capture());
    renameRefCaptor.getValue().apply(session);
    verify(linkedMode).addListener(inputArgumentCaptor.capture());
    inputArgumentCaptor.getValue().onLinkedModeExited(true, 0, 1);
    verify(refactoringServiceClient).applyLinkedModeRename(linkedRenameRefactoringApplyDto);
    verify(applyModelPromise).then(refactoringStatusCaptor.capture());
    refactoringStatusCaptor.getValue().apply(result);
    verify(locale).warningOperationTitle();
    verify(locale).renameWithWarnings();
    verify(locale).showRenameWizard();
    verify(locale).buttonCancel();
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), anyString(), anyString(), Matchers.<ConfirmCallback>anyObject(), Matchers.<CancelCallback>anyObject());
    verify(confirmDialog).show();
}
Also used : ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Example 4 with ConfirmDialog

use of org.eclipse.che.ide.api.dialogs.ConfirmDialog in project che by eclipse.

the class EditDebugConfigurationsPresenter method onRemoveClicked.

@Override
public void onRemoveClicked(final DebugConfiguration selectedConfiguration) {
    if (selectedConfiguration == null) {
        return;
    }
    final ConfirmCallback confirmCallback = new ConfirmCallback() {

        @Override
        public void accepted() {
            debugConfigurationsManager.removeConfiguration(selectedConfiguration);
            view.selectNextItem();
            fetchConfigurations();
        }
    };
    final ConfirmDialog confirmDialog = dialogFactory.createConfirmDialog(locale.editConfigurationsViewRemoveTitle(), locale.editConfigurationsRemoveConfirmation(selectedConfiguration.getName()), confirmCallback, null);
    confirmDialog.show();
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog)

Example 5 with ConfirmDialog

use of org.eclipse.che.ide.api.dialogs.ConfirmDialog in project che by eclipse.

the class JavaRefactoringRenameTest method renameRefactoringShouldBeWithWarningOrErrorStatus.

@Test
public void renameRefactoringShouldBeWithWarningOrErrorStatus() throws OperationException {
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    when(result.getSeverity()).thenReturn(WARNING);
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), anyString(), anyString(), Matchers.<ConfirmCallback>anyObject(), Matchers.<CancelCallback>anyObject())).thenReturn(confirmDialog);
    refactoringRename.refactor(textEditor);
    verify(refactoringServiceClient).createRenameRefactoring(createRenameRefactoringDto);
    verify(createRenamePromise).then(renameRefCaptor.capture());
    renameRefCaptor.getValue().apply(session);
    verify(linkedMode).addListener(inputArgumentCaptor.capture());
    inputArgumentCaptor.getValue().onLinkedModeExited(true, 0, 1);
    verify(refactoringServiceClient).applyLinkedModeRename(linkedRenameRefactoringApplyDto);
    verify(applyModelPromise).then(refactoringStatusCaptor.capture());
    refactoringStatusCaptor.getValue().apply(result);
    verify(locale).warningOperationTitle();
    verify(locale).renameWithWarnings();
    verify(locale).showRenameWizard();
    verify(locale).buttonCancel();
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), anyString(), anyString(), Matchers.<ConfirmCallback>anyObject(), Matchers.<CancelCallback>anyObject());
    verify(confirmDialog).show();
}
Also used : ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Aggregations

ConfirmDialog (org.eclipse.che.ide.api.dialogs.ConfirmDialog)14 Test (org.junit.Test)11 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)8 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)6 ArrayList (java.util.ArrayList)2 Operation (org.eclipse.che.api.promises.client.Operation)2 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)2 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 CommandImpl (org.eclipse.che.ide.api.command.CommandImpl)1 CancelCallback (org.eclipse.che.ide.api.dialogs.CancelCallback)1 InputCallback (org.eclipse.che.ide.api.dialogs.InputCallback)1 InputDialog (org.eclipse.che.ide.api.dialogs.InputDialog)1 Project (org.eclipse.che.ide.api.resources.Project)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)1 RefactoringStatusEntry (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatusEntry)1 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)1