Search in sources :

Example 11 with DefaultEvent

use of org.xwiki.eventstream.internal.DefaultEvent in project xwiki-platform by xwiki.

the class EventGroupTest method testGetMainEvent.

@Test
public void testGetMainEvent() {
    Event e1 = new DefaultEvent();
    e1.setImportance(Importance.BACKGROUND);
    Event e2 = new DefaultEvent();
    e2.setImportance(Importance.MAJOR);
    Event e3 = new DefaultEvent();
    e3.setImportance(Importance.MAJOR);
    Assert.assertNull(this.g.getMainEvent());
    this.g.addEvents(e1);
    Assert.assertEquals(e1, this.g.getMainEvent());
    this.g.addEvents(e2);
    Assert.assertEquals(e2, this.g.getMainEvent());
    this.g.addEvents(e3);
    Assert.assertEquals(e2, this.g.getMainEvent());
    this.g.clearEvents();
    Assert.assertNull(this.g.getMainEvent());
    this.g.clearEvents();
    this.g.addEvents(e3);
    Assert.assertEquals(e3, this.g.getMainEvent());
    this.g.addEvents(e2);
    Assert.assertEquals(e3, this.g.getMainEvent());
    this.g.addEvents(e1);
    Assert.assertEquals(e3, this.g.getMainEvent());
    this.g.clearEvents();
    this.g.addEvents(e2);
    Assert.assertEquals(e2, this.g.getMainEvent());
    this.g.addEvents(e3);
    Assert.assertEquals(e2, this.g.getMainEvent());
    this.g.addEvents(e1);
    Assert.assertEquals(e2, this.g.getMainEvent());
    this.g.clearEvents();
    this.g.addEvents(e3);
    Assert.assertEquals(e3, this.g.getMainEvent());
    this.g.addEvents(e3);
    Assert.assertEquals(e3, this.g.getMainEvent());
    this.g.addEvents(e2);
    Assert.assertEquals(e3, this.g.getMainEvent());
}
Also used : DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) Test(org.junit.Test)

Aggregations

DefaultEvent (org.xwiki.eventstream.internal.DefaultEvent)11 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Event (org.xwiki.eventstream.Event)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 Date (java.util.Date)1 Expectations (org.jmock.Expectations)1 EventFactory (org.xwiki.eventstream.EventFactory)1 EventStream (org.xwiki.eventstream.EventStream)1 TargetableEvent (org.xwiki.eventstream.TargetableEvent)1 DefaultEventStatus (org.xwiki.eventstream.internal.DefaultEventStatus)1 ModelContext (org.xwiki.model.ModelContext)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1