ChooseRunnerAction extends AbstractRunnerActions implements CustomComponentAction { public void selectDefaultRunner() { String runnerName = getDefaultRunnerName(); if (runnerName == null) { return; } for (Environment e : systemRunners) { if (runnerName.equals(e.getName())) { dropDownHeaderWidget.selectElement(resources.scopeSystem(), e.getName()); return; } } for (Environment e : projectRunners) { if (runnerName.equals(e.getName())) { dropDownHeaderWidget.selectElement(resources.scopeProject(), e.getName()); return; } } } @Inject  ChooseRunnerAction(RunnerResources resources,
                              RunnerLocalizationConstant locale,
                              AppContext appContext,
                              ActionManager actionManager,
                              DropDownListFactory dropDownListFactory); @Override void actionPerformed(ActionEvent e); @Override Widget createCustomComponent(Presentation presentation); void addSystemRunners(@NotNull List<Environment> systemEnvironments); void addProjectRunners(@NotNull List<Environment> projectEnvironments); @Nullable Environment selectEnvironment(); void selectDefaultRunner(); void setEmptyDefaultRunner();  }
@Test public void defaultRunnerShouldNotBeSelectedIfCurrentProjectIsNull() throws Exception { when(appContext.getCurrentProject()).thenReturn(null); action.selectDefaultRunner(); verify(dropDownHeaderWidget, never()).selectElement((SVGResource)any(), anyString()); }
@Test public void defaultRunnerShouldNotBeSelectedIfProjectDoesNotHaveAnyEnvironments() throws Exception { CurrentProject currentProject = mock(CurrentProject.class); when(appContext.getCurrentProject()).thenReturn(currentProject); action.selectDefaultRunner(); verify(dropDownHeaderWidget, never()).selectElement((SVGResource)any(), anyString()); }