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