use of org.xwiki.bridge.DocumentAccessBridge in project xwiki-platform by xwiki.
the class DefaultNotificationManagerTest method setUp.
@Before
public void setUp() throws Exception {
eventStream = mocker.getInstance(EventStream.class);
queryGenerator = mocker.getInstance(QueryGenerator.class);
documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
documentReferenceResolver = mocker.getInstance(DocumentReferenceResolver.TYPE_STRING);
notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
authorizationManager = mocker.getInstance(AuthorizationManager.class);
startDate = new Date(10);
when(documentReferenceResolver.resolve("xwiki:XWiki.UserA")).thenReturn(userReference);
query = mock(Query.class);
when(queryGenerator.generateQuery(any(DocumentReference.class), any(NotificationFormat.class), nullable(Date.class), nullable(Date.class), nullable(List.class))).thenReturn(query);
NotificationPreference pref1 = mock(NotificationPreference.class);
when(pref1.getProperties()).thenReturn(Collections.singletonMap(NotificationPreferenceProperty.EVENT_TYPE, "create"));
when(pref1.isNotificationEnabled()).thenReturn(true);
when(notificationPreferenceManager.getAllPreferences(userReference)).thenReturn(Arrays.asList(pref1));
}
use of org.xwiki.bridge.DocumentAccessBridge in project xwiki-platform by xwiki.
the class DefaultNotificationEmailUserPreferenceManagerTest method setUp.
@Before
public void setUp() throws Exception {
documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
referenceResolver = mocker.getInstance(DocumentReferenceResolver.TYPE_STRING);
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
currentUser = new DocumentReference("someWiki", "XWiki", "User");
when(documentAccessBridge.getCurrentUserReference()).thenReturn(currentUser);
}
use of org.xwiki.bridge.DocumentAccessBridge in project xwiki-platform by xwiki.
the class NotificationPreferenceScriptServiceTest method setUp.
@Before
public void setUp() throws Exception {
notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
authorizationManager = mocker.getInstance(ContextualAuthorizationManager.class);
targetableNotificationPreferenceBuilderProvider = mock(Provider.class);
when(targetableNotificationPreferenceBuilderProvider.get()).thenReturn(new DefaultTargetableNotificationPreferenceBuilder());
mocker.registerComponent(new DefaultParameterizedType(null, Provider.class, TargetableNotificationPreferenceBuilder.class), targetableNotificationPreferenceBuilderProvider);
}
use of org.xwiki.bridge.DocumentAccessBridge in project xwiki-platform by xwiki.
the class IntegrationTests method initialize.
@RenderingTestSuite.Initialized
public void initialize(MockingComponentManager componentManager) throws Exception {
Mockery mockery = new JUnit4Mockery();
// Document Access Bridge Mock
final DocumentAccessBridge mockDocumentAccessBridge = componentManager.registerMockComponent(mockery, DocumentAccessBridge.class);
// Image Storage Mock
final ImageStorage mockImageStorage = componentManager.registerMockComponent(mockery, ImageStorage.class);
// Configuration Mock
final FormulaMacroConfiguration mockConfiguration = componentManager.registerMockComponent(mockery, FormulaMacroConfiguration.class);
mockery.checking(new Expectations() {
{
atLeast(1).of(mockDocumentAccessBridge).getCurrentDocumentReference();
DocumentReference documentReference = new DocumentReference("wiki", "space", "page");
will(returnValue(documentReference));
AttachmentReference attachmentReference = new AttachmentReference("06fbba0acf130efd9e147fdfe91a943cc4f3e29972c6cd1d972e9aabf0900966", documentReference);
atLeast(2).of(mockDocumentAccessBridge).getAttachmentURL(attachmentReference, false);
will(returnValue("/xwiki/bin/view/space/page/06fbba0acf130efd9e147fdfe91a943cc4f3e29972c6cd1d972e9aabf0900966"));
atLeast(2).of(mockConfiguration).getRenderer();
will(returnValue("snuggletex"));
atLeast(2).of(mockImageStorage).get(with(any(String.class)));
will(returnValue(null));
atLeast(2).of(mockImageStorage).put(with(any(String.class)), with(any(ImageData.class)));
}
});
}
use of org.xwiki.bridge.DocumentAccessBridge in project xwiki-platform by xwiki.
the class DefaultOfficeViewerScriptServiceTest method view.
@Test
public void view() throws Exception {
Execution execution = mocker.getInstance(Execution.class);
when(execution.getContext()).thenReturn(new ExecutionContext());
AttachmentReference attachmentReference = new AttachmentReference("file.odt", new DocumentReference("wiki", "Space", "Page"));
DocumentModelBridge document = mock(DocumentModelBridge.class);
DocumentAccessBridge documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
when(documentAccessBridge.isDocumentViewable(attachmentReference.getDocumentReference())).thenReturn(true);
when(documentAccessBridge.getTranslatedDocumentInstance(attachmentReference.getDocumentReference())).thenReturn(document);
when(document.getSyntax()).thenReturn(Syntax.TEX_1_0);
XDOM xdom = new XDOM(Collections.<Block>emptyList());
OfficeViewer viewer = mocker.getInstance(OfficeViewer.class);
when(viewer.createView(attachmentReference, Collections.<String, String>emptyMap())).thenReturn(xdom);
BlockRenderer xhtmlRenderer = mocker.registerMockComponent(BlockRenderer.class, "xhtml/1.0");
Assert.assertEquals("", mocker.getComponentUnderTest().view(attachmentReference));
TransformationManager transformationManager = mocker.getInstance(TransformationManager.class);
verify(transformationManager).performTransformations(eq(xdom), notNull(TransformationContext.class));
verify(xhtmlRenderer).render(eq(xdom), notNull(WikiPrinter.class));
}
Aggregations