RemoteDebugAction extends ProjectAction { @Override public void updateProjectAction(@NotNull ActionEvent actionEvent) { final CurrentProject currentProject = appContext.getCurrentProject(); if (currentProject == null) { return; } String projectType = currentProject.getProjectDescription().getType(); ProjectTypeDefinition definition = typeRegistry.getProjectType(projectType); if (definition != null && definition.getRunnerCategories() != null && !definition.getRunnerCategories().isEmpty()) { String category = definition.getRunnerCategories().get(0); actionEvent.getPresentation().setEnabledAndVisible(JAVA.toString().equals(category)); } } @Inject  RemoteDebugAction(AppContext appContext,
                             RemoteDebugPresenter presenter,
                             JavaRuntimeLocalizationConstant locale,
                             ProjectTypeRegistry typeRegistry,
                             AnalyticsEventLogger eventLogger); @Override void updateProjectAction(@NotNull ActionEvent actionEvent); @Override void actionPerformed(@NotNull ActionEvent actionEvent);  }
@Test public void projectActionShouldNotBeUpdatedWhenCurrentProjectIsNull() throws Exception { when(appContext.getCurrentProject()).thenReturn(null); action.updateProjectAction(actionEvent); verify(typeRegistry, never()).getProjectType(SOME_TEXT); verify(actionEvent, never()).getPresentation(); }
@Test public void actionShouldBeUpdatedWhenProjectTypeIsJava() { action.updateProjectAction(actionEvent); verify(appContext).getCurrentProject(); verify(currentProject, times(2)).getProjectDescription(); verify(typeRegistry).getProjectType(SOME_TEXT); verify(actionEvent.getPresentation()).setEnabledAndVisible(true); }
@Test public void actionShouldBeUpdatedWhenProjectTypeIsNotJava() { when(definition.getRunnerCategories()).thenReturn(Arrays.asList(SOME_TEXT)); action.updateProjectAction(actionEvent); verify(appContext).getCurrentProject(); verify(currentProject, times(2)).getProjectDescription(); verify(typeRegistry).getProjectType(SOME_TEXT); verify(actionEvent.getPresentation(), never()).setEnabledAndVisible(true); }