Search in sources :

Example 11 with Event

use of org.xwiki.observation.event.Event in project xwiki-platform by xwiki.

the class XClassPropertyEventGeneratorListenerTest method testDeleteDocument.

@Test
public void testDeleteDocument() throws ComponentLookupException {
    this.xclassOrigin.addTextField("property", "Property", 30);
    final Event event = new XClassPropertyDeletedEvent(this.xclassOrigin.getField("property").getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentDeletedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
    // Make sure the listener generated a xobject added event
    verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext()));
}
Also used : DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) Event(org.xwiki.observation.event.Event) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) Test(org.junit.Test)

Example 12 with Event

use of org.xwiki.observation.event.Event in project xwiki-platform by xwiki.

the class XObjectEventGeneratorListenerTest method testDeleteDocument.

@Test
public void testDeleteDocument() throws ComponentLookupException {
    this.documentOrigin.addXObject(this.xobject);
    final Event event = new XObjectDeletedEvent(this.xobject.getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentDeletedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
    // Make sure the listener generated a xobject deleted event
    verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext()));
}
Also used : DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) Event(org.xwiki.observation.event.Event) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) Test(org.junit.Test)

Example 13 with Event

use of org.xwiki.observation.event.Event in project xwiki-platform by xwiki.

the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectPropertyModified.

@Test
public void testModifiedDocumentXObjectPropertyModified() throws ComponentLookupException {
    this.xobject.setStringValue("updatedproperty", "propertyvalue");
    BaseObject xobjectModified = this.xobject.clone();
    xobjectModified.setStringValue("updatedproperty", "propertyvaluemodified");
    this.document.addXObject(this.xobject);
    this.documentOrigin.addXObject(xobjectModified);
    final Event event = new XObjectPropertyUpdatedEvent(this.xobject.getField("updatedproperty").getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
    // Make sure the listener generated a xobject property updated event
    verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext()));
}
Also used : DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) Event(org.xwiki.observation.event.Event) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) BaseObject(com.xpn.xwiki.objects.BaseObject) Test(org.junit.Test)

Example 14 with Event

use of org.xwiki.observation.event.Event in project xwiki-platform by xwiki.

the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectAdded.

@Test
public void testModifiedDocumentXObjectAdded() throws ComponentLookupException {
    this.document.addXObject(this.xobject);
    final Event event = new XObjectAddedEvent(this.xobject.getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
    // Make sure the listener generated a xobject added event
    verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext()));
}
Also used : DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) Event(org.xwiki.observation.event.Event) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Test(org.junit.Test)

Example 15 with Event

use of org.xwiki.observation.event.Event in project celements-blog by celements.

the class ArticleUpdateListenerTest method testDeletedEvent.

@Test
public void testDeletedEvent() {
    Event event = listener.getDeletedEvent(null);
    assertNotNull(event);
    assertSame(ArticleDeletedEvent.class, event.getClass());
    assertTrue(event.matches(new ArticleDeletedEvent()));
    assertNotSame(listener.getDeletedEvent(null), event);
}
Also used : ArticleCreatingEvent(com.celements.blog.observation.event.ArticleCreatingEvent) ArticleCreatedEvent(com.celements.blog.observation.event.ArticleCreatedEvent) ArticleUpdatingEvent(com.celements.blog.observation.event.ArticleUpdatingEvent) ArticleDeletingEvent(com.celements.blog.observation.event.ArticleDeletingEvent) Event(org.xwiki.observation.event.Event) ArticleUpdatedEvent(com.celements.blog.observation.event.ArticleUpdatedEvent) ArticleDeletedEvent(com.celements.blog.observation.event.ArticleDeletedEvent) ArticleDeletedEvent(com.celements.blog.observation.event.ArticleDeletedEvent) Test(org.junit.Test)

Aggregations

Event (org.xwiki.observation.event.Event)54 Test (org.junit.Test)48 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)23 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)23 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)21 ArticleCreatingEvent (com.celements.blog.observation.event.ArticleCreatingEvent)9 BaseObject (com.xpn.xwiki.objects.BaseObject)9 ArticleCreatedEvent (com.celements.blog.observation.event.ArticleCreatedEvent)8 ArticleDeletedEvent (com.celements.blog.observation.event.ArticleDeletedEvent)8 ArticleDeletingEvent (com.celements.blog.observation.event.ArticleDeletingEvent)8 BlogCreatedEvent (com.celements.blog.observation.event.BlogCreatedEvent)8 BlogCreatingEvent (com.celements.blog.observation.event.BlogCreatingEvent)8 BlogDeletedEvent (com.celements.blog.observation.event.BlogDeletedEvent)8 BlogDeletingEvent (com.celements.blog.observation.event.BlogDeletingEvent)8 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)8 ArticleUpdatingEvent (com.celements.blog.observation.event.ArticleUpdatingEvent)7 ArrayList (java.util.ArrayList)7 ArticleUpdatedEvent (com.celements.blog.observation.event.ArticleUpdatedEvent)6 BlogUpdatedEvent (com.celements.blog.observation.event.BlogUpdatedEvent)6 BlogUpdatingEvent (com.celements.blog.observation.event.BlogUpdatingEvent)6