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());
}
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());
}
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();
}
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();
}
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();
}
Aggregations