Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azatsarynnyy committed Mar 6, 2017
1 parent c6e4ec3 commit 6d0184c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.eclipse.che.ide.command.editor;

import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwtmockito.GwtMockitoTestRunner;

import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
Expand Down Expand Up @@ -43,7 +44,6 @@
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.EMERGE_MODE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.WARNING;
Expand All @@ -60,7 +60,7 @@
*
* @author Artem Zatsarynnyi
*/
@RunWith(MockitoJUnitRunner.class)
@RunWith(GwtMockitoTestRunner.class)
public class CommandEditorTest {

private static final String EDITED_COMMAND_NAME = "build";
Expand Down Expand Up @@ -229,13 +229,12 @@ public void shouldSaveCommandWhenSavingRequested() throws Exception {
}

@Test
public void shouldCloseEditorAndRemoveListenerWhenEditedCommandRemoved() throws Exception {
public void shouldCloseEditorWhenEditedCommandRemoved() throws Exception {
ContextualCommand removedCommand = mock(ContextualCommand.class);
when(removedCommand.getName()).thenReturn(EDITED_COMMAND_NAME);

editor.onCommandRemoved(removedCommand);

verify(editorAgent).closeEditor(editor);
verify(commandManager).removeCommandChangedListener(editor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.gwtmockito.GwtMockitoTestRunner;

import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.api.promises.client.PromiseError;
import org.eclipse.che.ide.api.command.CommandGoal;
Expand Down Expand Up @@ -169,6 +170,7 @@ public void shouldCreateCommand() throws Exception {
when(commandManager.createCommand(anyString(),
anyString(),
any(ContextualCommand.ApplicableContext.class))).thenReturn(commandPromise);
when(commandPromise.then(any(Operation.class))).thenReturn(commandPromise);
when(commandPromise.catchError(any(Operation.class))).thenReturn(commandPromise);

// when
Expand All @@ -186,7 +188,7 @@ public void shouldCreateCommand() throws Exception {
any(ContextualCommand.ApplicableContext.class));
}

@Test
@Test(expected = OperationException.class)
public void shouldShowNotificationWhenFailedToCreateCommand() throws Exception {
// given
CommandType selectedCommandType = mock(CommandType.class);
Expand All @@ -204,6 +206,7 @@ public void shouldShowNotificationWhenFailedToCreateCommand() throws Exception {
when(commandManager.createCommand(anyString(),
anyString(),
any(ContextualCommand.ApplicableContext.class))).thenReturn(commandPromise);
when(commandPromise.then(any(Operation.class))).thenReturn(commandPromise);
when(commandPromise.catchError(any(Operation.class))).thenReturn(commandPromise);

// when
Expand Down Expand Up @@ -235,12 +238,9 @@ public void shouldDuplicateCommand() throws Exception {
presenter.onCommandDuplicate(command);

verify(commandManager).createCommand(command);
verify(commandPromise).then(commandOperationCaptor.capture());
commandOperationCaptor.getValue().apply(command);
verify(view).selectCommand(command);
}

@Test
@Test(expected = OperationException.class)
public void shouldShowNotificationWhenFailedToDuplicateCommand() throws Exception {
ContextualCommand command = mock(ContextualCommand.class);
when(commandManager.createCommand(any(ContextualCommand.class))).thenReturn(commandPromise);
Expand Down Expand Up @@ -333,7 +333,7 @@ public void shouldRefreshViewWhenCommandAdded() throws Exception {

presenter.onCommandAdded(command);

verify(refreshViewTask).delayAndSelectCommand(command);
verify(refreshViewTask).delayAndSelectCommand(isNull(ContextualCommand.class));
}

@Test
Expand Down

0 comments on commit 6d0184c

Please sign in to comment.