Search in sources :

Example 1 with DefaultEvent

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

the class EventGroupTest method testGetEventsIsReadonly.

@Test(expected = java.lang.UnsupportedOperationException.class)
public void testGetEventsIsReadonly() {
    this.g.addEvents(new DefaultEvent(), new DefaultEvent());
    this.g.getEvents().clear();
    Assert.fail("No exception thrown");
}
Also used : DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) Test(org.junit.Test)

Example 2 with DefaultEvent

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

the class EventGroupTest method testGetEventsIsNotLive.

@Test
public void testGetEventsIsNotLive() {
    this.g.addEvents(new DefaultEvent(), new DefaultEvent());
    Set<Event> view = this.g.getEvents();
    Assert.assertEquals(2, view.size());
    this.g.addEvents(new DefaultEvent());
    Assert.assertEquals(2, view.size());
}
Also used : DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) Test(org.junit.Test)

Example 3 with DefaultEvent

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

the class EventGroupTest method testConstructorsWithNullElements.

@Test
public void testConstructorsWithNullElements() {
    List<Event> eventsList = new ArrayList<Event>();
    eventsList.add(new DefaultEvent());
    eventsList.add(null);
    eventsList.add(new DefaultEvent());
    eventsList.add(new DefaultEvent());
    this.g = new EventGroup(eventsList);
    Assert.assertEquals(3, this.g.getEvents().size());
    Set<Event> eventsSet = new HashSet<Event>();
    eventsSet.add(new DefaultEvent());
    eventsSet.add(null);
    eventsSet.add(new DefaultEvent());
    eventsSet.add(new DefaultEvent());
    this.g = new EventGroup(eventsSet);
    Assert.assertEquals(3, this.g.getEvents().size());
    this.g = new EventGroup(new DefaultEvent(), null, new DefaultEvent(), null, new DefaultEvent());
    Assert.assertEquals(3, this.g.getEvents().size());
}
Also used : DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) ArrayList(java.util.ArrayList) DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with DefaultEvent

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

the class EventGroupTest method testClearEvents.

@Test
public void testClearEvents() {
    Assert.assertTrue(this.g.getEvents().isEmpty());
    this.g.addEvents(new DefaultEvent());
    this.g.addEvents(new DefaultEvent());
    this.g.addEvents(new DefaultEvent());
    Assert.assertFalse(this.g.getEvents().isEmpty());
    this.g.clearEvents();
    Assert.assertTrue(this.g.getEvents().isEmpty());
    this.g.clearEvents();
    Assert.assertTrue(this.g.getEvents().isEmpty());
    this.g.addEvents(new DefaultEvent());
    Assert.assertFalse(this.g.getEvents().isEmpty());
    this.g.clearEvents();
    Assert.assertTrue(this.g.getEvents().isEmpty());
}
Also used : DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) Test(org.junit.Test)

Example 5 with DefaultEvent

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

the class EventGroupTest method testConstructors.

@Test
public void testConstructors() {
    Event e = new DefaultEvent();
    Assert.assertNotNull(this.g.getEvents());
    Assert.assertEquals(0, this.g.getEvents().size());
    this.g = new EventGroup(e);
    Assert.assertEquals(1, this.g.getEvents().size());
    Assert.assertTrue(this.g.getEvents().contains(e));
    List<Event> l = new ArrayList<Event>();
    l.add(e);
    this.g = new EventGroup(l);
    Assert.assertEquals(1, this.g.getEvents().size());
    Assert.assertTrue(this.g.getEvents().contains(e));
    Set<Event> s = new HashSet<Event>();
    s.add(e);
    this.g = new EventGroup(s);
    Assert.assertEquals(1, this.g.getEvents().size());
    Assert.assertTrue(this.g.getEvents().contains(e));
    // Test that the internal set is not the same as the passed set
    s.remove(e);
    Assert.assertEquals(1, this.g.getEvents().size());
    Assert.assertTrue(this.g.getEvents().contains(e));
    s.add(new DefaultEvent());
    s.add(new DefaultEvent());
    Assert.assertEquals(1, this.g.getEvents().size());
    this.g = new EventGroup(s);
    Assert.assertEquals(2, this.g.getEvents().size());
}
Also used : DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) ArrayList(java.util.ArrayList) DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) HashSet(java.util.HashSet) 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