Search in sources :

Example 56 with EntityReference

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

the class ExplicitReferenceEntityReferenceResolverTest method testResolveWithIncompleteExplicitReference.

@Test
public void testResolveWithIncompleteExplicitReference() {
    try {
        this.resolver.resolve(null, EntityType.DOCUMENT, new EntityReference("wiki", EntityType.WIKI));
        Assert.fail("Should have raised an exception");
    } catch (IllegalArgumentException expected) {
        Assert.assertEquals("The resolver parameter doesn't contain an Entity Reference of type [DOCUMENT]", expected.getMessage());
    }
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 57 with EntityReference

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

the class ExplicitStringEntityReferenceResolverTest method resolveWithExplicitEntityReference.

@Test
public void resolveWithExplicitEntityReference() {
    EntityReference reference = this.resolver.resolve("space.page", EntityType.DOCUMENT, new EntityReference("wiki", EntityType.WIKI));
    Assert.assertEquals("page", reference.getName());
    Assert.assertEquals(EntityType.DOCUMENT, reference.getType());
    Assert.assertEquals("space", reference.getParent().getName());
    Assert.assertEquals(EntityType.SPACE, reference.getParent().getType());
    Assert.assertEquals("wiki", reference.getParent().getParent().getName());
    Assert.assertEquals(EntityType.WIKI, reference.getParent().getParent().getType());
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 58 with EntityReference

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

the class ExplicitStringEntityReferenceResolverTest method resolveWithExplicitReferenceWithHoles.

@Test
public void resolveWithExplicitReferenceWithHoles() {
    EntityReference reference = this.resolver.resolve("space.page", EntityType.DOCUMENT, new EntityReference("page", EntityType.DOCUMENT, new EntityReference("wiki", EntityType.WIKI)));
    Assert.assertEquals("page", reference.getName());
    Assert.assertEquals(EntityType.DOCUMENT, reference.getType());
    Assert.assertEquals("space", reference.getParent().getName());
    Assert.assertEquals(EntityType.SPACE, reference.getParent().getType());
    Assert.assertEquals("wiki", reference.getParent().getParent().getName());
    Assert.assertEquals(EntityType.WIKI, reference.getParent().getParent().getType());
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 59 with EntityReference

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

the class ExplicitStringEntityReferenceResolverTest method resolveWithExplicitDocumentReference.

@Test
public void resolveWithExplicitDocumentReference() {
    EntityReference reference = this.resolver.resolve("", EntityType.DOCUMENT, new DocumentReference("wiki", "space", "page"));
    Assert.assertEquals("page", reference.getName());
    Assert.assertEquals(EntityType.DOCUMENT, reference.getType());
    Assert.assertEquals("space", reference.getParent().getName());
    Assert.assertEquals(EntityType.SPACE, reference.getParent().getType());
    Assert.assertEquals("wiki", reference.getParent().getParent().getName());
    Assert.assertEquals(EntityType.WIKI, reference.getParent().getParent().getType());
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 60 with EntityReference

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

the class LocalStringEntityReferenceSerializerTest method serializeDocumentReference.

@Test
public void serializeDocumentReference() throws Exception {
    EntityReference reference = resolver.resolve("wiki:space.page", EntityType.DOCUMENT);
    Assert.assertEquals("space.page", 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