use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultStringEntityReferenceSerializerTest method serializeWikiReferences.
@Test
public void serializeWikiReferences() throws Exception {
EntityReference reference = resolver.resolve("wiki", EntityType.WIKI);
assertEquals("wiki", serializer.serialize(reference));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultStringEntityReferenceSerializerTest method serializeObjectReferences.
/**
* Tests resolving and re-serializing an object reference.
*/
@Test
public void serializeObjectReferences() {
EntityReference reference = resolver.resolve("wiki:space.page^Object", EntityType.OBJECT);
assertEquals("wiki:space.page^Object", serializer.serialize(reference));
// default values
reference = resolver.resolve("", EntityType.OBJECT);
assertEquals("defwiki:defspace.defpage^defobject", serializer.serialize(reference));
// property reference with no object
reference = resolver.resolve("wiki:space.page.property", EntityType.OBJECT);
assertEquals("defwiki:defspace.defpage^wiki:space.page.property", serializer.serialize(reference));
// test escaping character
reference = resolver.resolve("wiki:space.page^Obje\\^ct", EntityType.OBJECT);
assertEquals("wiki:space.page^Obje\\^ct", serializer.serialize(reference));
reference = resolver.resolve("wiki:spa^ce.page^Obje\\^ct", EntityType.OBJECT);
assertEquals("wiki:spa^ce.page^Obje\\^ct", serializer.serialize(reference));
reference = resolver.resolve(":.\\^@", EntityType.OBJECT);
assertEquals("defwiki:defspace.defpage^:.\\^@", serializer.serialize(reference));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultStringEntityReferenceSerializerTest method serializeReferencesWithChild.
@Test
public void serializeReferencesWithChild() {
EntityReference reference = resolver.resolve("wiki:Space.Page", EntityType.DOCUMENT);
assertEquals("wiki:Space", serializer.serialize(reference.getParent()));
assertEquals("wiki", serializer.serialize(reference.getParent().getParent()));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class ExplicitReferenceEntityReferenceResolverTest method testResolveWithExplicitEntityReference.
@Test
public void testResolveWithExplicitEntityReference() {
EntityReference reference = this.resolver.resolve(new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE)), 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());
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class ExplicitReferenceEntityReferenceResolverTest method testResolveWithExplicitReferenceWithHoles.
@Test
public void testResolveWithExplicitReferenceWithHoles() {
EntityReference reference = this.resolver.resolve(new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE)), 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());
}
Aggregations