use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class WikiObjectComponentManagerEventListenerProxyTest method testUnregisterObjectComponents.
@Test
public void testUnregisterObjectComponents() throws Exception {
ObjectReference testReference = mock(ObjectReference.class);
this.mocker.getComponentUnderTest().unregisterObjectComponents(testReference);
verify(this.wikiComponentManagerEventListenerHelper, times(1)).unregisterComponents(testReference);
}
use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class LESSObjectPropertyResourceReferenceTest method getContent.
@Test
public void getContent() throws Exception {
ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("property", new ObjectReference("class", new DocumentReference("wiki", "Space", "Document")));
LESSObjectPropertyResourceReference lessObjectPropertyResourceReference = new LESSObjectPropertyResourceReference(objectPropertyReference, entityReferenceSerializer, bridge);
// Mock
when(bridge.getProperty(eq(objectPropertyReference))).thenReturn("content");
// Test
assertEquals("content", lessObjectPropertyResourceReference.getContent("skin"));
}
use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class ModelFactory method toDocument.
public boolean toDocument(Document doc, org.xwiki.rest.model.jaxb.Page restPage) throws XWikiException {
boolean modified = false;
if (restPage.getContent() != null) {
doc.setContent(restPage.getContent());
modified = true;
}
if (restPage.getTitle() != null) {
doc.setTitle(restPage.getTitle());
modified = true;
}
if (restPage.getParent() != null) {
doc.setParent(restPage.getParent());
modified = true;
}
if (restPage.getSyntax() != null) {
doc.setSyntaxId(restPage.getSyntax());
modified = true;
}
doc.setHidden(restPage.isHidden());
// Set objects
if (restPage.getObjects() != null) {
Set<ObjectReference> newReferences = new HashSet<>();
// Add/update objects
for (ObjectSummary restObjectSummary : restPage.getObjects().getObjectSummaries()) {
if (restObjectSummary != null) {
org.xwiki.rest.model.jaxb.Object restObject = (org.xwiki.rest.model.jaxb.Object) restObjectSummary;
com.xpn.xwiki.api.Object xwikiObject = doc.getObject(restObject.getClassName(), restObject.getNumber());
if (xwikiObject == null) {
xwikiObject = doc.newObject(restObject.getClassName());
}
toObject(xwikiObject, restObject);
modified = true;
newReferences.add(xwikiObject.getReference());
}
}
// Remove objects
List<com.xpn.xwiki.api.Object> toRemove = new ArrayList<>();
for (Vector<com.xpn.xwiki.api.Object> objects : doc.getxWikiObjects().values()) {
for (com.xpn.xwiki.api.Object object : objects) {
if (!newReferences.contains(object.getReference())) {
toRemove.add(object);
}
}
}
for (com.xpn.xwiki.api.Object obj : toRemove) {
doc.removeObject(obj);
modified = true;
}
}
return modified;
}
Aggregations