Search in sources :

Example 16 with DocumentReference

use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.

the class EventAndFactoryTest method testDocument.

@Test
public void testDocument() {
    Assert.assertNull(this.defaultEvent.getDocument());
    DocumentReference ref = new DocumentReference("wiki", "Space", "Page");
    this.defaultEvent.setDocument(ref);
    Assert.assertEquals(ref, this.defaultEvent.getDocument());
    Assert.assertNull(this.rawEvent.getDocument());
    this.rawEvent.setDocument(ref);
    Assert.assertEquals(ref, this.rawEvent.getDocument());
    this.defaultEvent.setDocument(null);
    Assert.assertNull(this.defaultEvent.getDocument());
}
Also used : DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 17 with DocumentReference

use of org.xwiki.model.reference.DocumentReference 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());
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 18 with DocumentReference

use of org.xwiki.model.reference.DocumentReference 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());
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 19 with DocumentReference

use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.

the class EventAndFactoryTest method testUser.

@Test
public void testUser() {
    Assert.assertNotNull(this.defaultEvent.getUser());
    DocumentReference user = new DocumentReference("xwiki", "XWiki", "Admin");
    Assert.assertEquals(user, this.defaultEvent.getUser());
    user = new DocumentReference("wiki2", "XWiki", "jdoe");
    this.defaultEvent.setUser(user);
    Assert.assertEquals(user, this.defaultEvent.getUser());
    this.defaultEvent.setUser(null);
    Assert.assertNull(this.defaultEvent.getUser());
    Assert.assertNull(this.rawEvent.getUser());
    this.rawEvent.setUser(user);
    Assert.assertEquals(user, this.rawEvent.getUser());
}
Also used : DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 20 with DocumentReference

use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.

the class EventAndFactoryTest method testRelatedEntity.

@Test
public void testRelatedEntity() {
    Assert.assertNull(this.defaultEvent.getRelatedEntity());
    DocumentReference ref = new DocumentReference("wiki", "Space", "Page");
    this.defaultEvent.setRelatedEntity(ref);
    Assert.assertEquals(ref, this.defaultEvent.getRelatedEntity());
    this.defaultEvent.setRelatedEntity(null);
    Assert.assertNull(this.defaultEvent.getRelatedEntity());
    Assert.assertNull(this.rawEvent.getRelatedEntity());
}
Also used : DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Aggregations

DocumentReference (org.xwiki.model.reference.DocumentReference)1324 Test (org.junit.Test)711 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)482 BaseObject (com.xpn.xwiki.objects.BaseObject)250 XWikiContext (com.xpn.xwiki.XWikiContext)186 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)157 ArrayList (java.util.ArrayList)128 WikiReference (org.xwiki.model.reference.WikiReference)127 XWikiException (com.xpn.xwiki.XWikiException)121 EntityReference (org.xwiki.model.reference.EntityReference)113 SpaceReference (org.xwiki.model.reference.SpaceReference)96 XWiki (com.xpn.xwiki.XWiki)82 HashMap (java.util.HashMap)54 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)52 Expectations (org.jmock.Expectations)50 Before (org.junit.Before)50 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)46 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)45 AttachmentReference (org.xwiki.model.reference.AttachmentReference)44 Date (java.util.Date)42