use of org.xwiki.bridge.DocumentModelBridge in project xwiki-platform by xwiki.
the class DefaultIOTargetServiceTest method testGettersWhenTargetIsTypedRelativeDocument.
@Test
public void testGettersWhenTargetIsTypedRelativeDocument() throws Exception {
final DocumentModelBridge dmb = getMockery().mock(DocumentModelBridge.class);
getMockery().checking(new Expectations() {
{
// default resolver should be used
allowing(dabMock).getTranslatedDocumentInstance(new DocumentReference("xwiki", "Space", "Page"));
will(returnValue(dmb));
oneOf(dmb).getContent();
will(returnValue("defcontent"));
oneOf(dmb).getSyntax();
will(returnValue(new Syntax(SyntaxType.XWIKI, "2.0")));
}
});
String reference = "DOCUMENT://Space.Page";
assertEquals("defcontent", ioTargetService.getSource(reference));
assertEquals("xwiki/2.0", ioTargetService.getSourceSyntax(reference));
}
use of org.xwiki.bridge.DocumentModelBridge in project xwiki-platform by xwiki.
the class DefaultIOTargetServiceTest method testGetterWhenTargetIsTypedIndexedRelativeObjectProperty.
@Test
public void testGetterWhenTargetIsTypedIndexedRelativeObjectProperty() throws Exception {
final DocumentModelBridge dmb = getMockery().mock(DocumentModelBridge.class);
getMockery().checking(new Expectations() {
{
// this will fail if defaults fail, not very well isolated
allowing(classResolver).resolve("Classes.Class", new DocumentReference("xwiki", "Main", "WebHome"));
will(returnValue(new DocumentReference("xwiki", "Classes", "Class")));
oneOf(dabMock).getProperty(new DocumentReference("xwiki", "Main", "WebHome"), new DocumentReference("xwiki", "Classes", "Class"), 3, "property");
will(returnValue("defcontent"));
oneOf(dabMock).getTranslatedDocumentInstance(new DocumentReference("xwiki", "Main", "WebHome"));
will(returnValue(dmb));
oneOf(dmb).getSyntax();
will(returnValue(new Syntax(SyntaxType.XWIKI, "2.0")));
}
});
String reference = "OBJECT_PROPERTY://Classes.Class[3].property";
assertEquals("defcontent", ioTargetService.getSource(reference));
assertEquals("xwiki/2.0", ioTargetService.getSourceSyntax(reference));
}
use of org.xwiki.bridge.DocumentModelBridge in project xwiki-platform by xwiki.
the class DefaultIOTargetServiceTest method testGettersWhenTargetIsNonTypedDocument.
@Test
public void testGettersWhenTargetIsNonTypedDocument() throws Exception {
final DocumentModelBridge dmb = getMockery().mock(DocumentModelBridge.class);
getMockery().checking(new Expectations() {
{
allowing(dabMock).getTranslatedDocumentInstance(new DocumentReference("wiki", "Space", "Page"));
will(returnValue(dmb));
oneOf(dmb).getContent();
will(returnValue("defcontent"));
oneOf(dmb).getSyntax();
will(returnValue(new Syntax(SyntaxType.XWIKI, "2.0")));
}
});
String reference = "wiki:Space.Page";
assertEquals("defcontent", ioTargetService.getSource(reference));
assertEquals("xwiki/2.0", ioTargetService.getSourceSyntax(reference));
}
use of org.xwiki.bridge.DocumentModelBridge in project xwiki-platform by xwiki.
the class DefaultIOTargetServiceTest method testGettersWhenTargetIsTypedDocument.
@Test
public void testGettersWhenTargetIsTypedDocument() throws Exception {
final DocumentModelBridge dmb = getMockery().mock(DocumentModelBridge.class);
getMockery().checking(new Expectations() {
{
allowing(dabMock).getTranslatedDocumentInstance(new DocumentReference("wiki", "Space", "Page"));
will(returnValue(dmb));
oneOf(dmb).getContent();
will(returnValue("defcontent"));
oneOf(dmb).getSyntax();
will(returnValue(new Syntax(SyntaxType.XWIKI, "2.0")));
}
});
String reference = "DOCUMENT://wiki:Space.Page";
assertEquals("defcontent", ioTargetService.getSource(reference));
assertEquals("xwiki/2.0", ioTargetService.getSourceSyntax(reference));
}
use of org.xwiki.bridge.DocumentModelBridge in project xwiki-platform by xwiki.
the class DefaultIOTargetServiceTest method testGetterWhenTargetIsTypedObjectPropertyInRelativeDocument.
@Test
public void testGetterWhenTargetIsTypedObjectPropertyInRelativeDocument() throws Exception {
final DocumentModelBridge dmb = getMockery().mock(DocumentModelBridge.class);
getMockery().checking(new Expectations() {
{
allowing(classResolver).resolve("XWiki.Class", new DocumentReference("xwiki", "Main", "Page"));
will(returnValue(new DocumentReference("xwiki", "XWiki", "Class")));
oneOf(dabMock).getProperty(new DocumentReference("xwiki", "Main", "Page"), new DocumentReference("xwiki", "XWiki", "Class"), "property");
will(returnValue("defcontent"));
oneOf(dabMock).getTranslatedDocumentInstance(new DocumentReference("xwiki", "Main", "Page"));
will(returnValue(dmb));
oneOf(dmb).getSyntax();
will(returnValue(new Syntax(SyntaxType.XWIKI, "2.0")));
}
});
String reference = "OBJECT_PROPERTY://Page^XWiki.Class.property";
assertEquals("defcontent", ioTargetService.getSource(reference));
assertEquals("xwiki/2.0", ioTargetService.getSourceSyntax(reference));
}
Aggregations