use of com.xpn.xwiki.notify.DocChangeRule in project xwiki-platform by xwiki.
the class XWikiNotificationTest method testSaveDocumentFromAPIUsesCorrectOriginalDocument.
/**
* We only verify here that the saveDocument API calls the Notification Manager. Detailed tests of the notification
* classes are implemented in the notification package.
*/
public void testSaveDocumentFromAPIUsesCorrectOriginalDocument() throws Exception {
Mock mockRights = mock(XWikiRightService.class);
mockRights.stubs().method("hasAccessLevel").will(returnValue(true));
this.xwiki.setRightService((XWikiRightService) mockRights.proxy());
TestListener listener = new TestListener();
listener.expectedNewStatus = false;
getNotificationManager().addGeneralRule(new DocChangeRule(listener));
XWikiDocument original = new XWikiDocument(new DocumentReference("WikiDescriptor", "Space", "Page"));
original.setNew(false);
original.setContent("Old content");
XWikiDocument document = new XWikiDocument(new DocumentReference("WikiDescriptor", "Space", "Page"));
document.setContent("New content");
document.setOriginalDocument(original);
Document api = new Document(document, getContext());
api.save();
assertTrue("Listener not called", listener.hasListenerBeenCalled);
}
use of com.xpn.xwiki.notify.DocChangeRule in project xwiki-platform by xwiki.
the class XWikiNotificationTest method testSaveDocumentSendNotifications.
/**
* We only verify here that the saveDocument API calls the Notification Manager. Detailed tests of the notification
* classes are implemented in the notification package.
*/
public void testSaveDocumentSendNotifications() throws Exception {
TestListener listener = new TestListener();
getNotificationManager().addGeneralRule(new DocChangeRule(listener));
XWikiDocument document = new XWikiDocument(new DocumentReference("WikiDescriptor", "Space", "Page"));
this.xwiki.saveDocument(document, getContext());
assertTrue("Listener not called", listener.hasListenerBeenCalled);
}
Aggregations