Search in sources :

Example 1 with EventFactory

use of org.xwiki.eventstream.EventFactory in project xwiki-platform by xwiki.

the class MessageStreamTest method setupForNewMessage.

private Event setupForNewMessage() throws ComponentLookupException, Exception {
    final EventFactory mockEventFactory = getComponentManager().getInstance(EventFactory.class);
    final Event e = new DefaultEvent();
    e.setId(UUID.randomUUID().toString());
    final ModelContext mockContext = getComponentManager().getInstance(ModelContext.class);
    final EventStream mockEventStream = getComponentManager().getInstance(EventStream.class);
    getMockery().checking(new Expectations() {

        {
            exactly(1).of(mockEventFactory).createEvent();
            will(returnValue(e));
            exactly(1).of(mockContext).getCurrentEntityReference();
            will(returnValue(new DocumentReference("wiki", "Space", "Page")));
            exactly(1).of(mockEventStream).addEvent(e);
        }
    });
    return e;
}
Also used : ModelContext(org.xwiki.model.ModelContext) Expectations(org.jmock.Expectations) DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) EventStream(org.xwiki.eventstream.EventStream) EventFactory(org.xwiki.eventstream.EventFactory) Event(org.xwiki.eventstream.Event) DefaultEvent(org.xwiki.eventstream.internal.DefaultEvent) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

Expectations (org.jmock.Expectations)1 Event (org.xwiki.eventstream.Event)1 EventFactory (org.xwiki.eventstream.EventFactory)1 EventStream (org.xwiki.eventstream.EventStream)1 DefaultEvent (org.xwiki.eventstream.internal.DefaultEvent)1 ModelContext (org.xwiki.model.ModelContext)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1