use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class UidStringEntityReferenceSerializerTest method serializeAttachmentReference.
@Test
public void serializeAttachmentReference() throws Exception {
EntityReference reference = resolver.resolve("wiki:space.page@filename", EntityType.ATTACHMENT);
Assert.assertEquals("4:wiki5:space4:page8:filename", serializer.serialize(reference));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class UidStringEntityReferenceSerializerTest method serializeObjectPropertyReference.
/**
* Tests resolving and re-serializing an property reference.
*/
@Test
public void serializeObjectPropertyReference() {
EntityReference reference = resolver.resolve("wiki:space.page^wiki:space.class[0].prop", EntityType.OBJECT_PROPERTY);
Assert.assertEquals("4:wiki5:space4:page19:wiki:space.class[0]4:prop", serializer.serialize(reference));
reference = resolver.resolve("wiki:space.page^xwiki:space.class[0].prop", EntityType.OBJECT_PROPERTY);
Assert.assertEquals("4:wiki5:space4:page20:xwiki:space.class[0]4:prop", serializer.serialize(reference));
// test escaping character
reference = resolver.resolve("wiki:space.page^wiki:space.class[0].prop\\.erty", EntityType.OBJECT_PROPERTY);
Assert.assertEquals("4:wiki5:space4:page19:wiki:space.class[0]9:prop.erty", serializer.serialize(reference));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class UidStringEntityReferenceSerializerTest method serializeDocumentReference.
@Test
public void serializeDocumentReference() throws Exception {
EntityReference reference = resolver.resolve("wiki:space.page", EntityType.DOCUMENT);
Assert.assertEquals("4:wiki5:space4:page", serializer.serialize(reference));
reference = resolver.resolve("wiki1.wiki2:wiki3:some.space.page", EntityType.DOCUMENT);
Assert.assertEquals("17:wiki1.wiki2:wiki34:some5:space4:page", serializer.serialize(reference));
// Verify that passing null doesn't throw a NPE
Assert.assertNull(serializer.serialize(null));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class UidStringEntityReferenceSerializerTest method serializeClassPropertyReference.
/**
* Tests resolving and re-serializing an class property reference.
*/
@Test
public void serializeClassPropertyReference() {
EntityReference reference = resolver.resolve("wiki:space.page^ClassProperty", EntityType.CLASS_PROPERTY);
Assert.assertEquals("4:wiki5:space4:page13:ClassProperty", serializer.serialize(reference));
// test escaping character
reference = resolver.resolve("wiki:space.page^ClassPro\\^perty", EntityType.CLASS_PROPERTY);
Assert.assertEquals("4:wiki5:space4:page14:ClassPro^perty", serializer.serialize(reference));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class UidStringEntityReferenceSerializerTest 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));
}
Aggregations