LaunchAction extends AbstractRunnerAction { @Override public void perform(@NotNull Runner runner) { CurrentProject project = appContext.getCurrentProject(); if (project == null) { return; } project.setIsRunningEnabled(false); String projectName = project.getProjectDescription().getName(); String message = locale.environmentCooking(projectName); Notification notification = new Notification(message, PROGRESS, true); notificationManager.showNotification(notification); consoleContainer.printInfo(runner, message); RunnerAction statusAction = runnerActionFactory.createStatus(notification); addAction(statusAction); statusAction.perform(runner); outputAction.perform(runner); } @Inject  LaunchAction(NotificationManager notificationManager,
                        RunnerLocalizationConstant locale,
                        AppContext appContext,
                        ConsoleContainer consoleContainer,
                        RunnerActionFactory runnerActionFactory); @Override void perform(@NotNull Runner runner);  }
@Test public void nothingShouldHappenWhenACurrentProjectIsNull() throws Exception { when(appContext.getCurrentProject()).thenReturn(null); action.perform(runner); verify(locale, never()).environmentCooking(anyString()); verify(outputAction, never()).perform(runner); verify(notificationManager, never()).showNotification(Matchers.<Notification>any()); verify(runnerActionFactory, never()).createStatus(Matchers.<Notification>any()); }
@Test public void actionShouldBePerforms() throws Exception { when(appContext.getCurrentProject()).thenReturn(project); when(project.getProjectDescription()).thenReturn(projectDescriptor); when(projectDescriptor.getName()).thenReturn(SOME_TEXT); when(runnerActionFactory.createStatus(Matchers.<Notification>any())).thenReturn(statusAction); when(locale.environmentCooking(anyString())).thenReturn(SOME_TEXT); action.perform(runner); verify(project).setIsRunningEnabled(false); verify(locale).environmentCooking(SOME_TEXT); verify(notificationManager).showNotification(Matchers.<Notification>any()); verify(consoleContainer).printInfo(runner, SOME_TEXT); verify(runnerActionFactory).createStatus(Matchers.<Notification>any()); verify(statusAction).perform(runner); verify(outputAction).perform(runner); }