Search in sources :

Example 1 with DocumentSaveEvent

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

the class DocumentEventTest method testMatchesWithDocumentNameConstructor.

@Test
public void testMatchesWithDocumentNameConstructor() {
    DocumentSaveEvent event = new DocumentSaveEvent("document");
    Assert.assertTrue(event.matches(new DocumentSaveEvent("document")));
    Assert.assertFalse(event.matches(new DocumentSaveEvent("wrong")));
}
Also used : DocumentSaveEvent(org.xwiki.observation.event.DocumentSaveEvent) Test(org.junit.Test)

Example 2 with DocumentSaveEvent

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

the class DocumentEventTest method testMatchesWithRegexFilter.

@Test
public void testMatchesWithRegexFilter() {
    DocumentSaveEvent event = new DocumentSaveEvent(new RegexEventFilter(".*Doc.*"));
    Assert.assertTrue(event.matches(new DocumentSaveEvent("some.Document")));
    Assert.assertFalse(event.matches(new DocumentSaveEvent("some.document")));
}
Also used : RegexEventFilter(org.xwiki.observation.event.filter.RegexEventFilter) DocumentSaveEvent(org.xwiki.observation.event.DocumentSaveEvent) Test(org.junit.Test)

Example 3 with DocumentSaveEvent

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

the class DocumentEventTest method testMatchesWithEmptyConstructor.

@Test
public void testMatchesWithEmptyConstructor() {
    DocumentSaveEvent event = new DocumentSaveEvent();
    Assert.assertTrue(event.matches(new DocumentSaveEvent("whatever")));
}
Also used : DocumentSaveEvent(org.xwiki.observation.event.DocumentSaveEvent) Test(org.junit.Test)

Example 4 with DocumentSaveEvent

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

the class LegacyEventDispatcherTest method testLegacyDocumentSaveEventGetsDispatched.

@Test
public void testLegacyDocumentSaveEventGetsDispatched() throws Exception {
    this.registerListenerWithLegacyEvent(new DocumentSaveEvent());
    this.om.notify(new DocumentCreatedEvent(new DocumentReference("wiki", "space", "name")), null);
    // The notification is synchronous, so the following assertion will only be tested
    // once all matching event listeners have been notified.
    Assert.assertNotNull("Should have been notified by legacy event dispatcher", this.receivedEvent);
    Assert.assertEquals("Wrong event filter", "wiki:space.name", ((FilterableEvent) this.receivedEvent).getEventFilter().getFilter());
}
Also used : FilterableEvent(org.xwiki.observation.event.FilterableEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentSaveEvent(org.xwiki.observation.event.DocumentSaveEvent) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 DocumentSaveEvent (org.xwiki.observation.event.DocumentSaveEvent)4 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 FilterableEvent (org.xwiki.observation.event.FilterableEvent)1 RegexEventFilter (org.xwiki.observation.event.filter.RegexEventFilter)1