use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class XarExtensionPlan method getNextXarExtension.
public LocalExtension getNextXarExtension(DocumentReference documentReference) {
WikiReference wikiReference = documentReference.getWikiReference();
LocalDocumentReference localDocumentReference = new LocalDocumentReference(documentReference);
return getNextXarExtension(wikiReference.getName(), localDocumentReference);
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class EventAndFactoryTest method testSpace.
@Test
public void testSpace() {
Assert.assertNull(this.defaultEvent.getSpace());
DocumentReference doc = new DocumentReference("wiki1", "Space1", "Page");
SpaceReference space = new SpaceReference("Space2", new WikiReference("wiki2"));
this.defaultEvent.setDocument(doc);
Assert.assertEquals(doc.getLastSpaceReference(), this.defaultEvent.getSpace());
Assert.assertEquals("Space1", this.defaultEvent.getSpace().getName());
this.defaultEvent.setSpace(space);
Assert.assertEquals(space, this.defaultEvent.getSpace());
Assert.assertEquals("Space2", this.defaultEvent.getSpace().getName());
this.defaultEvent.setSpace(null);
Assert.assertEquals(doc.getLastSpaceReference(), this.defaultEvent.getSpace());
this.defaultEvent.setDocument(null);
Assert.assertNull(this.defaultEvent.getSpace());
Assert.assertNull(this.rawEvent.getSpace());
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class EventAndFactoryTest method testWiki.
@Test
public void testWiki() {
Assert.assertNull(this.defaultEvent.getWiki());
DocumentReference doc = new DocumentReference("wiki1", "Space1", "Page");
SpaceReference space = new SpaceReference("Space2", new WikiReference("wiki2"));
WikiReference wiki = new WikiReference("wiki3");
this.defaultEvent.setDocument(doc);
Assert.assertEquals(doc.getWikiReference(), this.defaultEvent.getWiki());
Assert.assertEquals("wiki1", this.defaultEvent.getWiki().getName());
this.defaultEvent.setSpace(space);
Assert.assertEquals(space.getRoot(), this.defaultEvent.getWiki());
Assert.assertEquals("wiki2", this.defaultEvent.getWiki().getName());
this.defaultEvent.setWiki(wiki);
Assert.assertEquals(wiki, this.defaultEvent.getWiki());
Assert.assertEquals("wiki3", this.defaultEvent.getWiki().getName());
this.defaultEvent.setWiki(null);
Assert.assertEquals(space.getRoot(), this.defaultEvent.getWiki());
this.defaultEvent.setSpace(null);
Assert.assertEquals(doc.getWikiReference(), this.defaultEvent.getWiki());
this.defaultEvent.setDocument(null);
Assert.assertNull(this.defaultEvent.getWiki());
Assert.assertNull(this.rawEvent.getWiki());
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class JavaIntegrationTest method registerConfiguration.
@BeforeComponent
public void registerConfiguration() throws Exception {
this.configuration = new TestMailSenderConfiguration(this.mail.getSmtp().getPort(), null, null, new Properties());
this.componentManager.registerComponent(MailSenderConfiguration.class, this.configuration);
// Set the current wiki in the Context
ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
XWikiContext xcontext = mock(XWikiContext.class);
when(xcontext.getWikiId()).thenReturn("wiki");
Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xwikiContextProvider.get()).thenReturn(xcontext);
this.componentManager.registerMockComponent(ExecutionContextManager.class);
this.componentManager.registerMockComponent(Execution.class);
this.componentManager.registerMockComponent(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
EnvironmentConfiguration environmentConfiguration = this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
when(environmentConfiguration.getPermanentDirectoryPath()).thenReturn(System.getProperty("java.io.tmpdir"));
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class NotificationPreferenceScriptServiceTest method isEventTypeEnabledForWiki.
@Test
public void isEventTypeEnabledForWiki() throws Exception {
WikiReference wiki = new WikiReference("whatever");
when(notificationPreferenceManager.getAllPreferences(wiki)).thenReturn(Collections.emptyList());
assertFalse(mocker.getComponentUnderTest().isEventTypeEnabled("update", NotificationFormat.ALERT, wiki.getName()));
NotificationPreference pref1 = mock(NotificationPreference.class);
NotificationPreference pref2 = mock(NotificationPreference.class);
when(pref1.getFormat()).thenReturn(NotificationFormat.EMAIL);
Map<NotificationPreferenceProperty, Object> properties1 = new HashMap<>();
properties1.put(NotificationPreferenceProperty.EVENT_TYPE, "update");
when(pref1.getProperties()).thenReturn(properties1);
when(pref2.getFormat()).thenReturn(NotificationFormat.ALERT);
Map<NotificationPreferenceProperty, Object> properties2 = new HashMap<>();
properties2.put(NotificationPreferenceProperty.EVENT_TYPE, "update");
when(pref2.getProperties()).thenReturn(properties2);
when(pref2.isNotificationEnabled()).thenReturn(true);
when(notificationPreferenceManager.getAllPreferences(wiki)).thenReturn(Arrays.asList(pref1, pref2));
assertTrue(mocker.getComponentUnderTest().isEventTypeEnabled("update", NotificationFormat.ALERT, wiki.getName()));
assertFalse(mocker.getComponentUnderTest().isEventTypeEnabled("update", NotificationFormat.EMAIL, wiki.getName()));
}
Aggregations