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