@Test public void get() throws Exception { WikiUIExtension wikiUIExtensionMenu1 = mock(WikiUIExtension.class); UIExtension fooExtension = mock(UIExtension.class); UIExtension barUIExtension = mock(UIExtension.class); PanelWikiUIExtension subwikiPanelExtension = mock(PanelWikiUIExtension.class); ComponentManager customComponentManager = mock(ComponentManager.class); when(contextComponentManagerProvider.get()).thenReturn(customComponentManager); when(customComponentManager.getInstanceList(UIExtension.class)) .thenReturn(Arrays.asList(subwikiPanelExtension, barUIExtension, wikiUIExtensionMenu1, fooExtension)); String panelsReferences = "Foo.WebHome,Menu.Menu1.WebHome,subwiki:Menu.WebHome"; panelUIExtensionManager.setConfiguration(panelsReferences); DocumentReference wikiUIExtensionMenu1DocumentReference = new DocumentReference("wiki", Arrays.asList("Menu", "Menu1"), "WebHome"); when(resolver.resolve("Menu.Menu1.WebHome")).thenReturn(wikiUIExtensionMenu1DocumentReference); when(wikiUIExtensionMenu1.getDocumentReference()).thenReturn(wikiUIExtensionMenu1DocumentReference); when(barUIExtension.getId()).thenReturn("Bar"); DocumentReference subwikiPanelExtensionReference = new DocumentReference("subwiki", "Menu", "WebHome"); when(resolver.resolve("subwiki:Menu.WebHome")).thenReturn(subwikiPanelExtensionReference); when(subwikiPanelExtension.getDocumentReference()).thenReturn(subwikiPanelExtensionReference); when(fooExtension.getId()).thenReturn("Foo.WebHome"); DocumentReference fooExtensionReference = new DocumentReference("wiki", "Foo", "WebHome"); when(resolver.resolve("Foo.WebHome")).thenReturn(fooExtensionReference); List<UIExtension> expectedList = Arrays.asList(fooExtension, wikiUIExtensionMenu1, subwikiPanelExtension); assertEquals(expectedList, panelUIExtensionManager.get("")); }
@Override public List<UIExtension> get(String extensionPointId) { List<UIExtension> panels = new ArrayList<>(); String panelConfigurationString = getConfiguration(); if (!StringUtils.isEmpty(panelConfigurationString)) { Map<DocumentReference, Integer> panelReferenceWithPosition = new HashMap<>(); String[] panelStringReferences = panelConfigurationString.split(","); for (int i = 0; i < panelStringReferences.length; i++) { panelReferenceWithPosition.put(resolver.resolve(panelStringReferences[i].trim()), i); } try { List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class); Map<UIExtension, Integer> panelsPositions = new HashMap<>(); for (UIExtension extension : allExtensions) { DocumentReference extensionId; if (extension instanceof WikiComponent) { WikiComponent wikiComponent = (WikiComponent) extension; extensionId = wikiComponent.getDocumentReference(); } else { extensionId = resolver.resolve(extension.getId()); } if (panelReferenceWithPosition.containsKey(extensionId)) { panelsPositions.put(extension, panelReferenceWithPosition.get(extensionId)); } } panels.addAll(panelsPositions.keySet()); panels.sort(Comparator.comparing(panelsPositions::get)); this.asyncContext.useComponent(UIExtension.class); } catch (ComponentLookupException e) { this.logger.error("Failed to lookup Panels instances, error: [{}]", e); } } return panels; }
AbstractPanelsUIExtensionManager implements UIExtensionManager { @Override public List<UIExtension> get(String extensionPointId) { List<UIExtension> panels = new ArrayList<>(); String panelConfigurationString = getConfiguration(); if (!StringUtils.isEmpty(panelConfigurationString)) { Map<DocumentReference, Integer> panelReferenceWithPosition = new HashMap<>(); String[] panelStringReferences = panelConfigurationString.split(","); for (int i = 0; i < panelStringReferences.length; i++) { panelReferenceWithPosition.put(resolver.resolve(panelStringReferences[i].trim()), i); } try { List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class); Map<UIExtension, Integer> panelsPositions = new HashMap<>(); for (UIExtension extension : allExtensions) { DocumentReference extensionId; if (extension instanceof WikiComponent) { WikiComponent wikiComponent = (WikiComponent) extension; extensionId = wikiComponent.getDocumentReference(); } else { extensionId = resolver.resolve(extension.getId()); } if (panelReferenceWithPosition.containsKey(extensionId)) { panelsPositions.put(extension, panelReferenceWithPosition.get(extensionId)); } } panels.addAll(panelsPositions.keySet()); panels.sort(Comparator.comparing(panelsPositions::get)); this.asyncContext.useComponent(UIExtension.class); } catch (ComponentLookupException e) { this.logger.error("Failed to lookup Panels instances, error: [{}]", e); } } return panels; } }
AbstractPanelsUIExtensionManager implements UIExtensionManager { @Override public List<UIExtension> get(String extensionPointId) { List<UIExtension> panels = new ArrayList<>(); String panelConfigurationString = getConfiguration(); if (!StringUtils.isEmpty(panelConfigurationString)) { Map<DocumentReference, Integer> panelReferenceWithPosition = new HashMap<>(); String[] panelStringReferences = panelConfigurationString.split(","); for (int i = 0; i < panelStringReferences.length; i++) { panelReferenceWithPosition.put(resolver.resolve(panelStringReferences[i].trim()), i); } try { List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class); Map<UIExtension, Integer> panelsPositions = new HashMap<>(); for (UIExtension extension : allExtensions) { DocumentReference extensionId; if (extension instanceof WikiComponent) { WikiComponent wikiComponent = (WikiComponent) extension; extensionId = wikiComponent.getDocumentReference(); } else { extensionId = resolver.resolve(extension.getId()); } if (panelReferenceWithPosition.containsKey(extensionId)) { panelsPositions.put(extension, panelReferenceWithPosition.get(extensionId)); } } panels.addAll(panelsPositions.keySet()); panels.sort(Comparator.comparing(panelsPositions::get)); this.asyncContext.useComponent(UIExtension.class); } catch (ComponentLookupException e) { this.logger.error("Failed to lookup Panels instances, error: [{}]", e); } } return panels; }  }
AbstractPanelsUIExtensionManager implements UIExtensionManager { @Override public List<UIExtension> get(String extensionPointId) { List<UIExtension> panels = new ArrayList<>(); String panelConfigurationString = getConfiguration(); if (!StringUtils.isEmpty(panelConfigurationString)) { Map<DocumentReference, Integer> panelReferenceWithPosition = new HashMap<>(); String[] panelStringReferences = panelConfigurationString.split(","); for (int i = 0; i < panelStringReferences.length; i++) { panelReferenceWithPosition.put(resolver.resolve(panelStringReferences[i].trim()), i); } try { List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class); Map<UIExtension, Integer> panelsPositions = new HashMap<>(); for (UIExtension extension : allExtensions) { DocumentReference extensionId; if (extension instanceof WikiComponent) { WikiComponent wikiComponent = (WikiComponent) extension; extensionId = wikiComponent.getDocumentReference(); } else { extensionId = resolver.resolve(extension.getId()); } if (panelReferenceWithPosition.containsKey(extensionId)) { panelsPositions.put(extension, panelReferenceWithPosition.get(extensionId)); } } panels.addAll(panelsPositions.keySet()); panels.sort(Comparator.comparing(panelsPositions::get)); this.asyncContext.useComponent(UIExtension.class); } catch (ComponentLookupException e) { this.logger.error("Failed to lookup Panels instances, error: [{}]", e); } } return panels; }  @Override List<UIExtension> get(String extensionPointId); }
AbstractPanelsUIExtensionManager implements UIExtensionManager { @Override public List<UIExtension> get(String extensionPointId) { List<UIExtension> panels = new ArrayList<>(); String panelConfigurationString = getConfiguration(); if (!StringUtils.isEmpty(panelConfigurationString)) { Map<DocumentReference, Integer> panelReferenceWithPosition = new HashMap<>(); String[] panelStringReferences = panelConfigurationString.split(","); for (int i = 0; i < panelStringReferences.length; i++) { panelReferenceWithPosition.put(resolver.resolve(panelStringReferences[i].trim()), i); } try { List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class); Map<UIExtension, Integer> panelsPositions = new HashMap<>(); for (UIExtension extension : allExtensions) { DocumentReference extensionId; if (extension instanceof WikiComponent) { WikiComponent wikiComponent = (WikiComponent) extension; extensionId = wikiComponent.getDocumentReference(); } else { extensionId = resolver.resolve(extension.getId()); } if (panelReferenceWithPosition.containsKey(extensionId)) { panelsPositions.put(extension, panelReferenceWithPosition.get(extensionId)); } } panels.addAll(panelsPositions.keySet()); panels.sort(Comparator.comparing(panelsPositions::get)); this.asyncContext.useComponent(UIExtension.class); } catch (ComponentLookupException e) { this.logger.error("Failed to lookup Panels instances, error: [{}]", e); } } return panels; }  @Override List<UIExtension> get(String extensionPointId);  }