use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method testPostDirectMessageWithLongMessage.
@Test
public void testPostDirectMessageWithLongMessage() throws Exception {
Event postedMessage = setupForDirectMessage();
this.stream.postDirectMessageToUser(StringUtils.repeat('a', 10000), this.targetUser);
Assert.assertEquals(StringUtils.repeat('a', 2000), postedMessage.getBody());
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method testPostDirectMessage.
@Test
public void testPostDirectMessage() throws Exception {
Event postedMessage = setupForDirectMessage();
this.stream.postDirectMessageToUser("Hello World!", this.targetUser);
Assert.assertEquals("Hello World!", postedMessage.getBody());
Assert.assertEquals(Importance.CRITICAL, postedMessage.getImportance());
Assert.assertEquals("directMessage", postedMessage.getType());
Assert.assertEquals("wiki:XWiki.JaneBuck", postedMessage.getStream());
Assert.assertEquals(new ObjectReference("XWiki.XWikiUsers", this.targetUser), postedMessage.getRelatedEntity());
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method setupForGroupMessage.
private Event setupForGroupMessage() throws ComponentLookupException, Exception {
final Event e = setupForNewMessage();
final EntityReferenceSerializer<String> mockSerializer = getComponentManager().getInstance(EntityReferenceSerializer.TYPE_STRING);
final DocumentAccessBridge mockBridge = getComponentManager().getInstance(DocumentAccessBridge.class);
getMockery().checking(new Expectations() {
{
exactly(1).of(mockBridge).exists(MessageStreamTest.this.targetGroup);
will(returnValue(true));
exactly(1).of(mockSerializer).serialize(MessageStreamTest.this.targetGroup);
will(returnValue("wiki:XWiki.MyFriends"));
}
});
return e;
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class BridgeEventStream method getRelatedEvents.
@Override
public EventGroup getRelatedEvents(Event e) {
XWikiContext context = getXWikiContext();
ActivityStreamPlugin plugin = getPlugin(context);
EventGroup result = new EventGroup();
try {
result.addEvents(convertActivitiesToEvents(plugin.getActivityStream().getRelatedEvents(eventConverter.convertEventToActivity(e), context)).toArray(new Event[0]));
} catch (ActivityStreamException ex) {
// Should not happen, and the eventual error was already reported downstream
}
return result;
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class DefaultNotificationManagerTest method createMockedEvent.
private Event createMockedEvent(String type, DocumentReference user, DocumentReference doc, Date date, String groupId) {
Event event = mock(Event.class);
when(event.getDate()).thenReturn(date);
when(event.getDocument()).thenReturn(doc);
when(event.getUser()).thenReturn(user);
when(event.getType()).thenReturn(type);
when(event.getGroupId()).thenReturn(groupId);
when(event.toString()).thenReturn(String.format("[%s] Event [%s] on document [%s] by [%s] on [%s]", groupId, type, doc, user, date.toString()));
return event;
}
Aggregations