EditorTreeProvider implements PermissionTreeProvider { public void registerEditor(final String editorId, final String editorName) { final SyncBeanDef<Activity> editorBeanDef = activityBeansCache.getActivity(editorId); WorkbenchEditorActivity editor = null; if (editorBeanDef != null) { try { editor = (WorkbenchEditorActivity) editorBeanDef.getInstance(); final String identifier = editor.getIdentifier(); final ResourceType resourceType = editor.getResourceType(); final Resource resource = new Resource() { @Override public String getIdentifier() { return identifier; } @Override public ResourceType getResourceType() { return resourceType; } }; registeredEditors.add(new RegisteredEditor(editorId, editorName, resource)); } finally { if (editor != null) { iocManager.destroyBean(editor); } } } } EditorTreeProvider(); @Inject  EditorTreeProvider(final ActivityBeansCache activityBeansCache,
                              final SyncBeanManager iocManager,
                              final PermissionManager permissionManager,
                              final PermissionTreeI18n i18n); @Override PermissionNode buildRootNode(); @Override void loadChildren(final PermissionNode parent,
                             final LoadOptions options,
                             final LoadCallback callback); int getRootNodePosition(); void setRootNodePosition(int rootNodePosition); void registerEditor(final String editorId,
                               final String editorName);  }
@Test public void testRegisterEditorDiscardsEditorInstance() { provider.registerEditor(EDITOR1_ID, EDITOR1_NAME); verify(iocManager).destroyBean(editorActivityCaptor.capture()); final WorkbenchEditorActivity editorActivity = editorActivityCaptor.getValue(); assertEquals(EDITOR1_ID, editorActivity.getIdentifier()); }
@Test public void testRegisterEditor() { provider.registerEditor(EDITOR1_ID, EDITOR1_NAME); final DefaultLoadOptions options = new DefaultLoadOptions(); options.setNodeNamePattern(""); provider.loadChildren(root, options, children -> assertEquals(children.size(), 1)); }