use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.
the class DefaultWikiComponentManagerEventListenerTest method onDocumentCreated.
@Test
public void onDocumentCreated() throws Exception {
onDocumentCreatedOrUpdated(new DocumentCreatedEvent(DOC_REFERENCE));
verify(this.wikiComponentManagerEventListenerHelper, times(2)).registerComponentList(Arrays.asList(this.wikiComponent));
verify(this.wikiComponentManagerEventListenerHelper, times(1)).unregisterComponents(any());
}
use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.
the class DefaultWikiComponentManagerEventListener method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
if (source instanceof DocumentModelBridge) {
// Get the document reference
DocumentModelBridge document = (DocumentModelBridge) source;
DocumentReference documentReference = document.getDocumentReference();
if (event instanceof DocumentCreatedEvent || event instanceof DocumentUpdatedEvent) {
registerDocumentComponents(document.getDocumentReference());
} else if (event instanceof DocumentDeletedEvent) {
// Unregister components from the deleted document, if any
this.wikiComponentManagerEventListenerHelper.unregisterComponents(documentReference);
}
/* If we are at application startup time, we have to instanciate every document or object that we can find
* in the wiki */
} else if (event instanceof ApplicationReadyEvent || event instanceof WikiReadyEvent) {
// These 2 events are created when the database is ready. We register all wiki components.
registerAllDocumentComponents();
}
}
use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.
the class ColorThemeListenerTest method getEvents.
@Test
public void getEvents() throws Exception {
List<Event> eventsToObserve = Arrays.<Event>asList(new DocumentCreatedEvent(), new DocumentUpdatedEvent(), new DocumentDeletedEvent());
assertEquals(eventsToObserve, mocker.getComponentUnderTest().getEvents());
}
use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.
the class SSXListenerTest method getEvents.
@Test
public void getEvents() throws Exception {
List<Event> eventsToObserve = Arrays.<Event>asList(new DocumentCreatedEvent(), new DocumentUpdatedEvent(), new DocumentDeletedEvent());
assertEquals(eventsToObserve, mocker.getComponentUnderTest().getEvents());
}
use of org.xwiki.bridge.event.DocumentCreatedEvent in project xwiki-platform by xwiki.
the class SkinListenerTest method getEvents.
@Test
public void getEvents() throws Exception {
List<Event> eventsToObserve = Arrays.<Event>asList(new DocumentCreatedEvent(), new DocumentUpdatedEvent(), new DocumentDeletedEvent());
assertEquals(eventsToObserve, mocker.getComponentUnderTest().getEvents());
}
Aggregations