Search in sources :

Example 11 with InputCallback

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

the class BranchPresenterTest method testOnRenameClickedWhenLocalBranchSelected.

@Test
public void testOnRenameClickedWhenLocalBranchSelected() throws Exception {
    reset(selectedBranch);
    when(service.branchRename(anyObject(), anyObject(), anyString(), anyString())).thenReturn(voidPromise);
    when(voidPromise.then(any(Operation.class))).thenReturn(voidPromise);
    when(voidPromise.catchError(any(Operation.class))).thenReturn(voidPromise);
    when(selectedBranch.getDisplayName()).thenReturn(BRANCH_NAME);
    when(selectedBranch.isRemote()).thenReturn(false);
    InputDialog inputDialog = mock(InputDialog.class);
    when(dialogFactory.createInputDialog(anyObject(), anyObject(), anyString(), anyInt(), anyInt(), anyObject(), anyObject())).thenReturn(inputDialog);
    selectBranch();
    presenter.onRenameClicked();
    verify(dialogFactory).createInputDialog(eq(null), eq(null), eq("branchName"), eq(0), eq("branchName".length()), inputCallbackCaptor.capture(), eq(null));
    InputCallback inputCallback = inputCallbackCaptor.getValue();
    inputCallback.accepted(RETURNED_MESSAGE);
    verify(selectedBranch, times(2)).getDisplayName();
    verify(dialogFactory, never()).createConfirmDialog(anyString(), anyString(), anyObject(), anyObject());
    verify(console, never()).printError(anyString());
    verify(notificationManager, never()).notify(anyString());
    verify(constant, never()).branchRenameFailed();
}
Also used : InputDialog(org.eclipse.che.ide.api.dialogs.InputDialog) InputCallback(org.eclipse.che.ide.api.dialogs.InputCallback) Operation(org.eclipse.che.api.promises.client.Operation) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 12 with InputCallback

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

the class BranchPresenterTest method testOnCreateClickedWhenBranchCreateRequestIsSuccessful.

@Test
public void testOnCreateClickedWhenBranchCreateRequestIsSuccessful() throws Exception {
    when(service.branchCreate(anyObject(), any(Path.class), anyString(), anyString())).thenReturn(branchPromise);
    when(branchPromise.then(any(Operation.class))).thenReturn(branchPromise);
    when(branchPromise.catchError(any(Operation.class))).thenReturn(branchPromise);
    InputDialog inputDialog = mock(InputDialog.class);
    when(dialogFactory.createInputDialog(anyString(), anyString(), anyObject(), anyObject())).thenReturn(inputDialog);
    presenter.showBranches(project);
    presenter.onCreateClicked();
    verify(dialogFactory).createInputDialog(anyString(), anyString(), inputCallbackCaptor.capture(), anyObject());
    InputCallback inputCallback = inputCallbackCaptor.getValue();
    inputCallback.accepted(BRANCH_NAME);
    verify(branchPromise).then(branchCaptor.capture());
    branchCaptor.getValue().apply(selectedBranch);
    verify(constant).branchTypeNew();
    verify(service).branchCreate(anyObject(), any(Path.class), anyString(), anyString());
    verify(service, times(2)).branchList(anyObject(), anyObject(), eq(LIST_ALL));
}
Also used : Path(org.eclipse.che.ide.resource.Path) InputDialog(org.eclipse.che.ide.api.dialogs.InputDialog) InputCallback(org.eclipse.che.ide.api.dialogs.InputCallback) Operation(org.eclipse.che.api.promises.client.Operation) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Aggregations

InputCallback (org.eclipse.che.ide.api.dialogs.InputCallback)12 InputDialog (org.eclipse.che.ide.api.dialogs.InputDialog)7 Test (org.junit.Test)6 Operation (org.eclipse.che.api.promises.client.Operation)5 Path (org.eclipse.che.ide.resource.Path)4 OperationException (org.eclipse.che.api.promises.client.OperationException)3 PromiseError (org.eclipse.che.api.promises.client.PromiseError)3 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)3 Resource (org.eclipse.che.ide.api.resources.Resource)3 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 Function (org.eclipse.che.api.promises.client.Function)2 FunctionException (org.eclipse.che.api.promises.client.FunctionException)2 Promise (org.eclipse.che.api.promises.client.Promise)2 RequestCall (org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.RequestCall)2 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)2 CancelCallback (org.eclipse.che.ide.api.dialogs.CancelCallback)2 RevealResourceEvent (org.eclipse.che.ide.resources.reveal.RevealResourceEvent)2 ArrayList (java.util.ArrayList)1 ConfirmDialog (org.eclipse.che.ide.api.dialogs.ConfirmDialog)1