@Test public void getWhenLookupError() throws Exception { ComponentManager failingCM = mock(ComponentManager.class); when(contextComponentManagerProvider.get()).thenReturn(failingCM); ComponentLookupException cle = new ComponentLookupException("error!"); when(failingCM.getInstanceList(UIExtension.class)).thenThrow(cle); String panelsReferences = "non empty configuration list of document references"; panelUIExtensionManager.setConfiguration(panelsReferences); assertEquals(0, panelUIExtensionManager.get("").size()); ILoggingEvent logEvent = logCapture.getLogEvent(0); assertEquals("Failed to lookup Panels instances, error: [{}]", logEvent.getMessage()); assertEquals("error!", logEvent.getThrowableProxy().getMessage()); }
@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);  }