@Test public void onDocumentUpdated() { DocumentReference alice = new DocumentReference("wiki", "Users", "Alice"); DocumentReference aliceFR = new DocumentReference(alice, Locale.FRENCH); XWikiDocument document = mock(XWikiDocument.class); when(document.getDocumentReference()).thenReturn(alice); when(document.getDocumentReferenceWithLocale()).thenReturn(aliceFR); this.listener.onEvent(new DocumentUpdatedEvent(), document, null); verify(this.tree, never()).setCustomizedExtensionPage(eq(alice), any(Boolean.class)); when(this.tree.isExtensionPage(alice)).thenReturn(true); this.listener.onEvent(new DocumentUpdatedEvent(), document, null); verify(this.tree).setCustomizedExtensionPage(aliceFR, false); when(this.customizationDetectorProvider.get().isCustomized(aliceFR)).thenReturn(true); this.listener.onEvent(new DocumentUpdatedEvent(), document, null); verify(this.tree).setCustomizedExtensionPage(aliceFR, true); }
@SuppressWarnings("unchecked") @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentUpdatedEvent) { XWikiDocument document = (XWikiDocument) source; if (this.tree.isExtensionPage(document.getDocumentReference())) { updateCustomizedFlag(document.getDocumentReferenceWithLocale()); } } else if (event instanceof ApplicationReadyEvent) { addExtensionDocuments(this.wikiDescriptorManagerProvider.get().getCurrentWikiId()); } else if (event instanceof WikiReadyEvent) { addExtensionDocuments((String) source); } else if (event instanceof XarExtensionInstalledEvent) { addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUninstalledEvent) { removeExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUpgradedEvent) { ((Collection<InstalledExtension>) data).stream().forEach( oldInstalledExtension -> removeExtensionDocuments((ExtensionEvent) event, oldInstalledExtension)); addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } }
InstalledExtensionDocumentListener extends AbstractEventListener { @SuppressWarnings("unchecked") @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentUpdatedEvent) { XWikiDocument document = (XWikiDocument) source; if (this.tree.isExtensionPage(document.getDocumentReference())) { updateCustomizedFlag(document.getDocumentReferenceWithLocale()); } } else if (event instanceof ApplicationReadyEvent) { addExtensionDocuments(this.wikiDescriptorManagerProvider.get().getCurrentWikiId()); } else if (event instanceof WikiReadyEvent) { addExtensionDocuments((String) source); } else if (event instanceof XarExtensionInstalledEvent) { addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUninstalledEvent) { removeExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUpgradedEvent) { ((Collection<InstalledExtension>) data).stream().forEach( oldInstalledExtension -> removeExtensionDocuments((ExtensionEvent) event, oldInstalledExtension)); addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } } }
InstalledExtensionDocumentListener extends AbstractEventListener { @SuppressWarnings("unchecked") @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentUpdatedEvent) { XWikiDocument document = (XWikiDocument) source; if (this.tree.isExtensionPage(document.getDocumentReference())) { updateCustomizedFlag(document.getDocumentReferenceWithLocale()); } } else if (event instanceof ApplicationReadyEvent) { addExtensionDocuments(this.wikiDescriptorManagerProvider.get().getCurrentWikiId()); } else if (event instanceof WikiReadyEvent) { addExtensionDocuments((String) source); } else if (event instanceof XarExtensionInstalledEvent) { addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUninstalledEvent) { removeExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUpgradedEvent) { ((Collection<InstalledExtension>) data).stream().forEach( oldInstalledExtension -> removeExtensionDocuments((ExtensionEvent) event, oldInstalledExtension)); addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } } InstalledExtensionDocumentListener(); }
InstalledExtensionDocumentListener extends AbstractEventListener { @SuppressWarnings("unchecked") @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentUpdatedEvent) { XWikiDocument document = (XWikiDocument) source; if (this.tree.isExtensionPage(document.getDocumentReference())) { updateCustomizedFlag(document.getDocumentReferenceWithLocale()); } } else if (event instanceof ApplicationReadyEvent) { addExtensionDocuments(this.wikiDescriptorManagerProvider.get().getCurrentWikiId()); } else if (event instanceof WikiReadyEvent) { addExtensionDocuments((String) source); } else if (event instanceof XarExtensionInstalledEvent) { addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUninstalledEvent) { removeExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUpgradedEvent) { ((Collection<InstalledExtension>) data).stream().forEach( oldInstalledExtension -> removeExtensionDocuments((ExtensionEvent) event, oldInstalledExtension)); addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } } InstalledExtensionDocumentListener(); @SuppressWarnings("unchecked") @Override void onEvent(Event event, Object source, Object data); }
InstalledExtensionDocumentListener extends AbstractEventListener { @SuppressWarnings("unchecked") @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentUpdatedEvent) { XWikiDocument document = (XWikiDocument) source; if (this.tree.isExtensionPage(document.getDocumentReference())) { updateCustomizedFlag(document.getDocumentReferenceWithLocale()); } } else if (event instanceof ApplicationReadyEvent) { addExtensionDocuments(this.wikiDescriptorManagerProvider.get().getCurrentWikiId()); } else if (event instanceof WikiReadyEvent) { addExtensionDocuments((String) source); } else if (event instanceof XarExtensionInstalledEvent) { addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUninstalledEvent) { removeExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } else if (event instanceof XarExtensionUpgradedEvent) { ((Collection<InstalledExtension>) data).stream().forEach( oldInstalledExtension -> removeExtensionDocuments((ExtensionEvent) event, oldInstalledExtension)); addExtensionDocuments((ExtensionEvent) event, (InstalledExtension) source); } } InstalledExtensionDocumentListener(); @SuppressWarnings("unchecked") @Override void onEvent(Event event, Object source, Object data); static final String HINT; }