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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations