Search in sources :

Example 11 with ConfirmDialog

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

the class SshKeyManagerPresenterTest method testOnDeleteClickedWhenDeleteKeyConfirmed.

@Test
public void testOnDeleteClickedWhenDeleteKeyConfirmed() {
    when(sshPairDto.getService()).thenReturn(SshKeyManagerPresenter.VCS_SSH_SERVICE);
    when(sshPairDto.getName()).thenReturn(GITHUB_HOST);
    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(), confirmCallbackCaptor.capture(), (CancelCallback) anyObject());
    ConfirmCallback confirmCallback = confirmCallbackCaptor.getValue();
    confirmCallback.accepted();
    verify(confirmDialog).show();
    verify(service).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), eq(GITHUB_HOST));
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Example 12 with ConfirmDialog

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

the class SshKeyManagerPresenterTest method testShouldRefreshKeysAfterSuccessfulDeleteKey.

@Test
public void testShouldRefreshKeysAfterSuccessfulDeleteKey() 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).then(operationSshPairDTOsCapture.capture());
    operationSshPairDTOsCapture.getValue().apply(sshPairDtoArray);
    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).setPairs(eq(sshPairDtoArray));
}
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 13 with ConfirmDialog

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

the class SshKeyManagerPresenterTest method testOnDeleteClickedWhenDeleteKeyIsFailure.

@Test
public void testOnDeleteClickedWhenDeleteKeyIsFailure() 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);
    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).catchError(operationErrorCapture.capture());
    operationErrorCapture.getValue().apply(JsPromiseError.create(""));
    verify(confirmDialog).show();
    verify(service).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), anyString());
    verify(notificationManager).notify(anyString(), eq(StatusNotification.Status.FAIL), eq(FLOAT_MODE));
    verify(service, never()).getPairs(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE));
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Example 14 with ConfirmDialog

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

the class ProcessesPanelPresenterTest method shouldShowConfirmDialogWhenCommandHasNotFinished.

@Test
public void shouldShowConfirmDialogWhenCommandHasNotFinished() throws Exception {
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    ProcessTreeNode commandNode = mock(ProcessTreeNode.class);
    when(outputConsole.isFinished()).thenReturn(false);
    presenter.consoles.put(PROCESS_ID, outputConsole);
    when(commandNode.getId()).thenReturn(PROCESS_ID);
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), anyObject(), anyObject())).thenReturn(confirmDialog);
    presenter.onCloseCommandOutputClick(commandNode);
    verify(commandNode).getId();
    verify(view, never()).hideProcessOutput(anyString());
    verify(view, never()).removeProcessNode(anyObject());
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), anyObject(), anyObject());
    verify(confirmDialog).show();
}
Also used : ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) 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