OpenedFilesPersistenceComponent implements PersistenceComponent { @Override public List<ActionDescriptor> getActions(String projectPath) { final EditorAgent editorAgent = editorAgentProvider.get(); final List<ActionDescriptor> actions = new ArrayList<>(); final String openFileActionId = actionManager.getId(openFileAction); final Map<String, EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors(); for (EditorPartPresenter editor : openedEditors.values()) { actions.add(dtoFactory.createDto(ActionDescriptor.class) .withId(openFileActionId) .withParameters(Collections.singletonMap(FILE_PARAM_ID, editor.getEditorInput().getFile().getPath()))); } return actions; } @Inject  OpenedFilesPersistenceComponent(Provider<EditorAgent> editorAgentProvider,
                                           ActionManager actionManager,
                                           OpenFileAction openFileAction,
                                           DtoFactory dtoFactory); @Override List<ActionDescriptor> getActions(String projectPath);  }
@Test public void shouldGetActions() { configureOpenedEditors(); ActionDescriptor action = mock(ActionDescriptor.class); when(action.withId(anyString())).thenReturn(action); when(action.withParameters(anyMapOf(String.class, String.class))).thenReturn(action); when(dtoFactory.createDto(eq(ActionDescriptor.class))).thenReturn(action); NavigableMap<String, EditorPartPresenter> editors = new TreeMap<>(); editors.put("/foo", editorPartPresenter); when(editorAgent.getOpenedEditors()).thenReturn(editors); when(editorPartPresenter.getEditorInput()).thenReturn(editorInput); when(editorInput.getFile()).thenReturn(virtualFile); when(virtualFile.getPath()).thenReturn(FILE_PATH); List<ActionDescriptor> actionDescriptors = component.getActions(PROJECT_PATH); verify(action).withId(anyString()); verify(action).withParameters(eq(Collections.singletonMap(FILE_PARAM_ID, FILE_PATH))); assertEquals(1, actionDescriptors.size()); assertTrue(actionDescriptors.contains(action)); }