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");
}
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());
}
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());
}
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());
}
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());
}
Aggregations