Search in sources :

Example 1 with MessageDialog

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

the class ResetFilesPresenterTest method testOnResetClickedWhenNothingToReset.

@Test
public void testOnResetClickedWhenNothingToReset() throws Exception {
    MessageDialog messageDialog = mock(MessageDialog.class);
    final Status status = mock(Status.class);
    IndexFile indexFile = mock(IndexFile.class);
    when(dtoFactory.createDto(IndexFile.class)).thenReturn(indexFile);
    when(constant.messagesWarningTitle()).thenReturn("Warning");
    when(constant.indexIsEmpty()).thenReturn("Index is Empty");
    when(dialogFactory.createMessageDialog(constant.messagesWarningTitle(), constant.indexIsEmpty(), null)).thenReturn(messageDialog);
    when(indexFile.isIndexed()).thenReturn(true);
    when(indexFile.withIndexed(anyBoolean())).thenReturn(indexFile);
    when(indexFile.withPath(anyString())).thenReturn(indexFile);
    List<String> changes = new ArrayList<String>();
    changes.add("Change");
    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);
    presenter.onResetClicked();
    verify(view).close();
    verify(console).print(anyString());
    verify(constant, times(2)).nothingToReset();
}
Also used : Status(org.eclipse.che.api.git.shared.Status) IndexFile(org.eclipse.che.api.git.shared.IndexFile) 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 2 with MessageDialog

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

the class HistoryPresenterTest method shouldShowDialogIfNothingToCompare.

@Test
public void shouldShowDialogIfNothingToCompare() throws Exception {
    MessageDialog dialog = mock(MessageDialog.class);
    when(dialogFactory.createMessageDialog(eq("title"), eq("error message"), any(ConfirmCallback.class))).thenReturn(dialog);
    presenter.show();
    presenter.onRevisionSelected(mock(Revision.class));
    presenter.onCompareClicked();
    verify(stringPromise).then(stringCaptor.capture());
    stringCaptor.getValue().apply("");
    verify(dialog).show();
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) Revision(org.eclipse.che.api.git.shared.Revision) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 3 with MessageDialog

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

the class HistoryPresenterTest method shouldShowDialogOnInitCommitError.

@Test
public void shouldShowDialogOnInitCommitError() throws Exception {
    PromiseError error = mock(PromiseError.class);
    ServerException exception = mock(ServerException.class);
    when(exception.getErrorCode()).thenReturn(ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
    when(error.getCause()).thenReturn(exception);
    when(constant.initCommitWasNotPerformed()).thenReturn("error message");
    MessageDialog dialog = mock(MessageDialog.class);
    when(dialogFactory.createMessageDialog(eq("title"), eq("error message"), any(ConfirmCallback.class))).thenReturn(dialog);
    presenter.show();
    verify(logPromise).catchError(promiseErrorCaptor.capture());
    promiseErrorCaptor.getValue().apply(error);
    verify(dialog).show();
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) ServerException(org.eclipse.che.ide.commons.exception.ServerException) PromiseError(org.eclipse.che.api.promises.client.PromiseError) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 4 with MessageDialog

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

the class WorkspaceEventsHandlerTest method onErrorEventReceivedTest.

@Test
public void onErrorEventReceivedTest() throws Exception {
    WorkspaceConfigDto workspaceConfig = mock(WorkspaceConfigDto.class);
    when(workspace.getConfig()).thenReturn(workspaceConfig);
    when(workspaceServiceClient.getWorkspaces(anyInt(), anyInt())).thenReturn(workspacesPromise);
    List<WorkspaceDto> workspaces = new ArrayList<>(1);
    workspaces.add(workspace);
    MessageDialog errorDialog = mock(MessageDialog.class);
    when(dialogFactory.createMessageDialog(anyString(), anyString(), (ConfirmCallback) anyObject())).thenReturn(errorDialog);
    when(workspaceStatusEvent.getEventType()).thenReturn(ERROR);
    workspaceEventsHandler.trackWorkspaceEvents(workspace, callback);
    workspaceEventsHandler.workspaceStatusSubscriptionHandler.onMessageReceived(workspaceStatusEvent);
    verify(workspacesPromise).then(workspacesCaptor.capture());
    workspacesCaptor.getValue().apply(workspaces);
    verify(notificationManager).notify(anyString(), eq(StatusNotification.Status.FAIL), eq(FLOAT_MODE));
    verify(startWorkspaceNotification).show(WORKSPACE_ID);
    verify(eventBus, times(2)).fireEvent(Matchers.<WorkspaceStoppedEvent>anyObject());
    verify(eventBus, times(2)).fireEvent(Matchers.<WsAgentStateEvent>anyObject());
    verify(errorDialog).show();
}
Also used : ArrayList(java.util.ArrayList) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) Test(org.junit.Test)

Example 5 with MessageDialog

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

the class GitHubAuthenticatorImplTest method onAuthenticatedWhenGenerateKeysIsFailure.

@Test
public void onAuthenticatedWhenGenerateKeysIsFailure() throws Exception {
    String userId = "userId";
    OAuthStatus authStatus = mock(OAuthStatus.class);
    SshKeyUploader keyProvider = 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(keyProvider);
    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);
    gitHubAuthenticator.authenticate(null, getCallBack());
    gitHubAuthenticator.onAuthenticated(authStatus);
    verify(keyProvider).uploadKey(eq(userId), generateKeyCallbackCaptor.capture());
    AsyncCallback<Void> generateKeyCallback = generateKeyCallbackCaptor.getValue();
    generateKeyCallback.onFailure(new Exception(""));
    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));
}
Also used : SshKeyUploader(org.eclipse.che.plugin.ssh.key.client.SshKeyUploader) CurrentUser(org.eclipse.che.ide.api.app.CurrentUser) 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)

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