Search in sources :

Example 31 with DocumentUpdatedEvent

use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.

the class XClassPropertyEventGeneratorListenerTest method testModifiedDocumentXClassPropertyDeleted.

@Test
public void testModifiedDocumentXClassPropertyDeleted() throws ComponentLookupException {
    this.xclassOrigin.addTextField("property", "Property", 30);
    final Event event = new XClassPropertyDeletedEvent(this.xclassOrigin.getField("property").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 32 with DocumentUpdatedEvent

use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.

the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectDeleted.

@Test
public void testModifiedDocumentXObjectDeleted() throws ComponentLookupException {
    this.documentOrigin.addXObject(this.xobject);
    final Event event = new XObjectDeletedEvent(this.xobject.getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(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 : 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 33 with DocumentUpdatedEvent

use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.

the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectModified.

@Test
public void testModifiedDocumentXObjectModified() throws ComponentLookupException {
    this.document.addXObject(this.xobject);
    this.documentOrigin.addXObject(this.xobject.clone());
    this.xobject.setStringValue("newproperty", "newvalue");
    final Event event = new XObjectUpdatedEvent(this.xobject.getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
    // Make sure the listener generated a xobject 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) Test(org.junit.Test)

Example 34 with DocumentUpdatedEvent

use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.

the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectPropertyAdded.

@Test
public void testModifiedDocumentXObjectPropertyAdded() throws ComponentLookupException {
    this.document.addXObject(this.xobject);
    this.documentOrigin.addXObject(this.xobject.clone());
    this.xobject.setStringValue("newproperty", "newvalue");
    final Event event = new XObjectPropertyAddedEvent(this.xobject.getField("newproperty").getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
    // Make sure the listener generated a xobject property 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 35 with DocumentUpdatedEvent

use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.

the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectPropertyDeleted.

@Test
public void testModifiedDocumentXObjectPropertyDeleted() throws ComponentLookupException {
    this.document.addXObject(this.xobject.clone());
    this.documentOrigin.addXObject(this.xobject);
    this.xobject.setStringValue("deletedproperty", "deletedvalue");
    final Event event = new XObjectPropertyDeletedEvent(this.xobject.getField("deletedproperty").getReference());
    this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(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 : 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)

Aggregations

DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)45 Test (org.junit.Test)30 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)26 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)25 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)16 DocumentReference (org.xwiki.model.reference.DocumentReference)13 Event (org.xwiki.observation.event.Event)13 XWikiContext (com.xpn.xwiki.XWikiContext)9 ArrayList (java.util.ArrayList)6 UntypedRecordableEventDescriptor (org.xwiki.eventstream.UntypedRecordableEventDescriptor)5 BaseObject (com.xpn.xwiki.objects.BaseObject)4 ObservationManager (org.xwiki.observation.ObservationManager)4 DocumentUpdatingEvent (org.xwiki.bridge.event.DocumentUpdatingEvent)3 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)2 AttachmentAddedEvent (com.xpn.xwiki.internal.event.AttachmentAddedEvent)2 AttachmentDeletedEvent (com.xpn.xwiki.internal.event.AttachmentDeletedEvent)2 AttachmentUpdatedEvent (com.xpn.xwiki.internal.event.AttachmentUpdatedEvent)2 Date (java.util.Date)2 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)2 ActionExecutedEvent (org.xwiki.bridge.event.ActionExecutedEvent)2