use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method setupForDirectMessage.
private Event setupForDirectMessage() 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.targetUser);
will(returnValue(true));
exactly(1).of(mockSerializer).serialize(MessageStreamTest.this.targetUser);
will(returnValue("wiki:XWiki.JaneBuck"));
}
});
return e;
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method testPostPersonalMessageWithEmptyMessage.
@Test
public void testPostPersonalMessageWithEmptyMessage() throws Exception {
Event postedMessage = setupForPersonalMessage();
this.stream.postPersonalMessage("");
Assert.assertEquals("", postedMessage.getBody());
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method testPostGroupMessage.
@Test
public void testPostGroupMessage() throws Exception {
Event postedMessage = setupForGroupMessage();
this.stream.postMessageToGroup("Hello Friends!", this.targetGroup);
Assert.assertEquals("Hello Friends!", postedMessage.getBody());
Assert.assertEquals(Importance.MAJOR, postedMessage.getImportance());
Assert.assertEquals("groupMessage", postedMessage.getType());
Assert.assertEquals("wiki:XWiki.MyFriends", postedMessage.getStream());
Assert.assertEquals(new ObjectReference("XWiki.XWikiGroups", this.targetGroup), postedMessage.getRelatedEntity());
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method testGetRecentPersonalMessagesWhenQueryFails.
@Test
public void testGetRecentPersonalMessagesWhenQueryFails() throws Exception {
final Query mockQuery = getMockQuery();
final QueryManager mockQueryManager = getComponentManager().getInstance(QueryManager.class);
final EventStream mockEventStream = getComponentManager().getInstance(EventStream.class);
final DocumentAccessBridge mockBridge = getComponentManager().getInstance(DocumentAccessBridge.class);
final EntityReferenceSerializer<String> mockSerializer = getComponentManager().getInstance(EntityReferenceSerializer.TYPE_STRING);
getMockery().checking(new Expectations() {
{
allowing(mockBridge).getCurrentUserReference();
will(returnValue(MessageStreamTest.this.currentUser));
allowing(mockSerializer).serialize(MessageStreamTest.this.currentUser);
will(returnValue("wiki:XWiki.JohnDoe"));
exactly(1).of(mockQuery).setLimit(30);
will(returnValue(mockQuery));
exactly(1).of(mockQuery).setOffset(0);
will(returnValue(mockQuery));
allowing(mockQuery).bindValue(with(any(String.class)), with("wiki:XWiki.JohnDoe"));
allowing(mockQueryManager).createQuery(with(aNonNull(String.class)), with(aNonNull(String.class)));
will(returnValue(mockQuery));
exactly(1).of(mockEventStream).searchEvents(with(mockQuery));
will(throwException(new QueryException("", null, null)));
}
});
List<Event> result = this.stream.getRecentPersonalMessages();
Assert.assertNotNull(result);
Assert.assertTrue(result.isEmpty());
}
use of org.xwiki.eventstream.Event in project xwiki-platform by xwiki.
the class MessageStreamTest method testPostDirectMessageWithEmptyMessage.
@Test
public void testPostDirectMessageWithEmptyMessage() throws Exception {
Event postedMessage = setupForDirectMessage();
this.stream.postDirectMessageToUser("", this.targetUser);
Assert.assertEquals("", postedMessage.getBody());
}
Aggregations