Search in sources :

Example 6 with MessageDialog

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

the class MavenPagePresenterTest method warningWindowShouldBeShowedIfProjectEstimationHasSomeError.

@Test
public void warningWindowShouldBeShowedIfProjectEstimationHasSomeError() throws Exception {
    final String dialogTitle = "Not valid Maven project";
    PromiseError promiseError = mock(PromiseError.class);
    MessageDialog messageDialog = mock(MessageDialog.class);
    context.put(WIZARD_MODE_KEY, UPDATE.toString());
    when(promiseError.getMessage()).thenReturn(TEXT);
    when(localization.mavenPageErrorDialogTitle()).thenReturn(dialogTitle);
    when(dialogFactory.createMessageDialog(anyString(), anyString(), anyObject())).thenReturn(messageDialog);
    when(sourceEstimationPromise.then(Matchers.<Operation<SourceEstimation>>anyObject())).thenReturn(sourceEstimationPromise);
    when(sourceEstimationPromise.catchError(Matchers.<Operation<PromiseError>>anyObject())).thenReturn(sourceEstimationPromise);
    mavenPagePresenter.init(projectConfig);
    verify(containerPromise).then(optionContainerCapture.capture());
    optionContainerCapture.getValue().apply(optionalContainer);
    verify(sourceEstimationPromise).catchError(containerArgumentErrorCapture.capture());
    containerArgumentErrorCapture.getValue().apply(promiseError);
    verify(promiseError).getMessage();
    verify(dialogFactory).createMessageDialog(dialogTitle, TEXT, null);
    verify(messageDialog).show();
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) SourceEstimation(org.eclipse.che.api.project.shared.dto.SourceEstimation) Matchers.anyString(org.mockito.Matchers.anyString) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) Test(org.junit.Test)

Example 7 with MessageDialog

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

the class JavaRefactoringRenameTest method renameRefactoringShouldBeShowErrorWindow.

@Test
public void renameRefactoringShouldBeShowErrorWindow() throws OperationException {
    PromiseError arg = Mockito.mock(PromiseError.class);
    MessageDialog dialog = Mockito.mock(MessageDialog.class);
    when(result.getSeverity()).thenReturn(OK);
    when(locale.renameRename()).thenReturn("renameTitle");
    when(locale.renameOperationUnavailable()).thenReturn("renameBody");
    when(dialogFactory.createMessageDialog(anyString(), anyString(), anyObject())).thenReturn(dialog);
    refactoringRename.refactor(textEditor);
    verify(createRenamePromise).then(renameRefCaptor.capture());
    renameRefCaptor.getValue().apply(session);
    verify(createRenamePromise).catchError(refactoringErrorCaptor.capture());
    refactoringErrorCaptor.getValue().apply(arg);
    verify(dialogFactory).createMessageDialog("renameTitle", "renameBody", null);
    verify(dialog).show();
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) Test(org.junit.Test)

Example 8 with MessageDialog

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

the class GitHubAuthenticatorImplTest method onAuthenticatedWhenGetFailedKeyIsSuccess.

@Test
public void onAuthenticatedWhenGetFailedKeyIsSuccess() throws Exception {
    String userId = "userId";
    SshPairDto pair = mock(SshPairDto.class);
    List<SshPairDto> pairs = new ArrayList<>();
    pairs.add(pair);
    OAuthStatus authStatus = mock(OAuthStatus.class);
    SshKeyUploader keyUploader = mock(SshKeyUploader.class);
    CurrentUser user = mock(CurrentUser.class);
    ProfileDto profile = mock(ProfileDto.class);
    MessageDialog messageDialog = mock(MessageDialog.class);
    when(view.isGenerateKeysSelected()).thenReturn(true);
    when(registry.getUploader(GITHUB_HOST)).thenReturn(keyUploader);
    when(appContext.getCurrentUser()).thenReturn(user);
    when(user.getProfile()).thenReturn(profile);
    when(profile.getUserId()).thenReturn(userId);
    when(dialogFactory.createMessageDialog(anyString(), anyString(), Matchers.<ConfirmCallback>anyObject())).thenReturn(messageDialog);
    when(pair.getName()).thenReturn(GITHUB_HOST);
    when(pair.getService()).thenReturn(SshKeyManagerPresenter.VCS_SSH_SERVICE);
    gitHubAuthenticator.authenticate(null, getCallBack());
    gitHubAuthenticator.onAuthenticated(authStatus);
    verify(keyUploader).uploadKey(eq(userId), generateKeyCallbackCaptor.capture());
    AsyncCallback<Void> generateKeyCallback = generateKeyCallbackCaptor.getValue();
    generateKeyCallback.onFailure(new Exception(""));
    verify(sshPairDTOsPromise).then(operationSshPairDTOsCapture.capture());
    operationSshPairDTOsCapture.getValue().apply(pairs);
    verify(view).isGenerateKeysSelected();
    verify(registry).getUploader(eq(GITHUB_HOST));
    verify(appContext).getCurrentUser();
    verify(dialogFactory).createMessageDialog(anyString(), anyString(), Matchers.<ConfirmCallback>anyObject());
    verify(messageDialog).show();
    verify(sshServiceClient).getPairs(eq(SshKeyManagerPresenter.VCS_SSH_SERVICE));
    verify(sshServiceClient).deletePair(eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), eq(GITHUB_HOST));
}
Also used : SshPairDto(org.eclipse.che.api.ssh.shared.dto.SshPairDto) SshKeyUploader(org.eclipse.che.plugin.ssh.key.client.SshKeyUploader) CurrentUser(org.eclipse.che.ide.api.app.CurrentUser) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) OAuthStatus(org.eclipse.che.security.oauth.OAuthStatus) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) ProfileDto(org.eclipse.che.api.user.shared.dto.ProfileDto) Test(org.junit.Test)

Example 9 with MessageDialog

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

the class ResetFilesPresenterTest method testShowDialogWhenStatusRequestIsSuccessfulButIndexIsEmpty.

@Test
public void testShowDialogWhenStatusRequestIsSuccessfulButIndexIsEmpty() throws Exception {
    MessageDialog messageDialog = mock(MessageDialog.class);
    when(constant.messagesWarningTitle()).thenReturn("Warning");
    when(constant.indexIsEmpty()).thenReturn("Index is Empty");
    when(dialogFactory.createMessageDialog(anyString(), anyString(), anyObject())).thenReturn(messageDialog);
    final Status status = mock(Status.class);
    List<String> changes = new ArrayList<>();
    when(status.getAdded()).thenReturn(changes);
    when(status.getChanged()).thenReturn(changes);
    when(status.getRemoved()).thenReturn(changes);
    presenter.showDialog(project);
    verify(statusPromise).then(statusPromiseCaptor.capture());
    statusPromiseCaptor.getValue().apply(status);
    verify(dialogFactory).createMessageDialog(eq("Warning"), eq("Index is Empty"), anyObject());
    verify(view, never()).setIndexedFiles(anyObject());
    verify(view, never()).showDialog();
}
Also used : Status(org.eclipse.che.api.git.shared.Status) ArrayList(java.util.ArrayList) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) Matchers.anyString(org.mockito.Matchers.anyString) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 10 with MessageDialog

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

the class SshKeyManagerPresenterTest method testOnViewClickedWhenGetPublicKeyIsSuccess.

@Test
public void testOnViewClickedWhenGetPublicKeyIsSuccess() {
    when(sshPairDto.getPublicKey()).thenReturn("publicKey");
    when(sshPairDto.getName()).thenReturn("name");
    MessageDialog messageDialog = mock(MessageDialog.class);
    when(dialogFactory.createMessageDialog(anyString(), anyString(), (ConfirmCallback) anyObject())).thenReturn(messageDialog);
    presenter.onViewClicked(sshPairDto);
    verify(showSshKeyView).show("name", "publicKey");
}
Also used : MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) Test(org.junit.Test)

Aggregations

MessageDialog (org.eclipse.che.ide.api.dialogs.MessageDialog)10 Test (org.junit.Test)10 Matchers.anyString (org.mockito.Matchers.anyString)5 ArrayList (java.util.ArrayList)4 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)4 PromiseError (org.eclipse.che.api.promises.client.PromiseError)3 Status (org.eclipse.che.api.git.shared.Status)2 ProfileDto (org.eclipse.che.api.user.shared.dto.ProfileDto)2 CurrentUser (org.eclipse.che.ide.api.app.CurrentUser)2 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)2 SshKeyUploader (org.eclipse.che.plugin.ssh.key.client.SshKeyUploader)2 OAuthStatus (org.eclipse.che.security.oauth.OAuthStatus)2 IndexFile (org.eclipse.che.api.git.shared.IndexFile)1 Revision (org.eclipse.che.api.git.shared.Revision)1 SourceEstimation (org.eclipse.che.api.project.shared.dto.SourceEstimation)1 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)1 WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)1 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)1 ServerException (org.eclipse.che.ide.commons.exception.ServerException)1