Search in sources :

Example 61 with EntityReference

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

the class LocalUidStringEntityReferenceSerializerTest method serializeReferenceWithChild.

@Test
public void serializeReferenceWithChild() {
    EntityReference reference = resolver.resolve("wiki:Space.Page", EntityType.DOCUMENT);
    Assert.assertEquals("5:Space", serializer.serialize(reference.getParent()));
    Assert.assertEquals("", serializer.serialize(reference.getParent().getParent()));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 62 with EntityReference

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

the class LocalUidStringEntityReferenceSerializerTest method serializeDocumentReference.

@Test
public void serializeDocumentReference() throws Exception {
    EntityReference reference = resolver.resolve("wiki:space.page", EntityType.DOCUMENT);
    Assert.assertEquals("5:space4:page", serializer.serialize(reference));
    reference = resolver.resolve("wiki1.wiki2:wiki3:some.space.page", EntityType.DOCUMENT);
    Assert.assertEquals("4:some5:space4:page", serializer.serialize(reference));
    // Verify that passing null doesn't throw a NPE
    Assert.assertNull(serializer.serialize(null));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 63 with EntityReference

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

the class LocalUidStringEntityReferenceSerializerTest method serializeRelativeReference.

@Test
public void serializeRelativeReference() {
    EntityReference reference = new EntityReference("page", EntityType.DOCUMENT);
    Assert.assertEquals("4:page", serializer.serialize(reference));
    reference = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE));
    Assert.assertEquals("5:space4:page", serializer.serialize(reference));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 64 with EntityReference

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

the class LocalUidStringEntityReferenceSerializerTest method serializeSpaceReference.

@Test
public void serializeSpaceReference() throws Exception {
    EntityReference reference = resolver.resolve("wiki:space1.space2", EntityType.SPACE);
    Assert.assertEquals("6:space16:space2", serializer.serialize(reference));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 65 with EntityReference

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

the class LocalUidStringEntityReferenceSerializerTest method serializeAttachmentReference.

@Test
public void serializeAttachmentReference() throws Exception {
    EntityReference reference = resolver.resolve("wiki:space.page@filename", EntityType.ATTACHMENT);
    Assert.assertEquals("5:space4:page8:filename", serializer.serialize(reference));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Aggregations

EntityReference (org.xwiki.model.reference.EntityReference)338 Test (org.junit.Test)157 DocumentReference (org.xwiki.model.reference.DocumentReference)107 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)39 BaseObject (com.xpn.xwiki.objects.BaseObject)38 ArrayList (java.util.ArrayList)27 XWikiContext (com.xpn.xwiki.XWikiContext)24 WikiReference (org.xwiki.model.reference.WikiReference)24 SpaceReference (org.xwiki.model.reference.SpaceReference)23 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)18 XWikiException (com.xpn.xwiki.XWikiException)17 EntityType (org.xwiki.model.EntityType)11 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)10 EntityReferenceProvider (org.xwiki.model.reference.EntityReferenceProvider)9 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)8 XDOM (org.xwiki.rendering.block.XDOM)8 URL (java.net.URL)7 AttachmentReference (org.xwiki.model.reference.AttachmentReference)7 HashMap (java.util.HashMap)6 Before (org.junit.Before)6