use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.
the class PropertyChangedRuleTest method testVerifySingleObjectNotChanged.
public void testVerifySingleObjectNotChanged() throws XWikiException {
XWikiDocument newDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
XWikiDocument oldDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
BaseObject oldObj = oldDoc.newObject(this.testClassName, this.context);
BaseObject newObj = newDoc.newObject(this.testClassName, this.context);
oldObj.setStringValue(this.testPropertyName, "value");
newObj.setStringValue(this.testPropertyName, "value");
this.passed = false;
this.rule.verify(newDoc, oldDoc, this.context);
assertFalse("My notification should not have been called", this.passed);
// The rule should be symmetric. Do the inverse test too
this.passed = false;
this.rule.verify(oldDoc, newDoc, this.context);
assertFalse("My notification should not have been called", this.passed);
}
use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.
the class PropertyChangedRuleTest method testVerifyObjectAdded.
public void testVerifyObjectAdded() throws XWikiException {
XWikiDocument newDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
XWikiDocument oldDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
BaseObject newObj = newDoc.newObject(this.testClassName, this.context);
newObj.setStringValue(this.testPropertyName, "value2");
this.passed = false;
this.rule.verify(newDoc, oldDoc, this.context);
assertTrue("My notification should have been called", this.passed);
// The rule should be symmetric. Do the inverse test too.
this.passed = false;
this.rule.verify(oldDoc, newDoc, this.context);
assertTrue("My notification should have been called", this.passed);
}
use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.
the class PropertyChangedRuleTest method testVerifyMultipleObjectsPropertyNotChanged.
public void testVerifyMultipleObjectsPropertyNotChanged() throws XWikiException {
XWikiDocument newDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
XWikiDocument oldDoc = new XWikiDocument(new DocumentReference("Test", "Test", "TestDoc"));
BaseObject newObj1 = newDoc.newObject(this.testClassName, this.context);
newObj1.setStringValue(this.testPropertyName, "value1");
BaseObject newObj2 = newDoc.newObject(this.testClassName, this.context);
newObj2.setStringValue(this.testPropertyName, "value2");
BaseObject oldObj1 = oldDoc.newObject(this.testClassName, this.context);
oldObj1.setStringValue(this.testPropertyName, "value1");
BaseObject oldObj2 = oldDoc.newObject(this.testClassName, this.context);
oldObj2.setStringValue(this.testPropertyName, "value2");
this.passed = false;
this.rule.verify(newDoc, oldDoc, this.context);
assertFalse("My notification should not have been called", this.passed);
// The rule should be symmetric. Do the inverse test too.
this.passed = false;
this.rule.verify(oldDoc, newDoc, this.context);
assertFalse("My notification should not have been called", this.passed);
}
use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.
the class SSXListener method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
XWikiDocument document = (XWikiDocument) source;
String currentWiki = wikiDescriptorManager.getCurrentWikiId();
DocumentReference ssxDocRef = new DocumentReference(currentWiki, "XWiki", "StyleSheetExtension");
List<BaseObject> ssxObjects = document.getXObjects(ssxDocRef);
if (ssxObjects != null && !ssxObjects.isEmpty()) {
for (BaseObject obj : ssxObjects) {
if (obj == null) {
continue;
}
if ("LESS".equals(obj.getStringValue("contentType"))) {
ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("code", new BaseObjectReference(ssxDocRef, obj.getNumber(), document.getDocumentReference()));
LESSResourceReference lessResourceReference = lessResourceReferenceFactory.createReferenceForXObjectProperty(objectPropertyReference);
lessResourcesCache.clearFromLESSResource(lessResourceReference);
colorThemeCache.clearFromLESSResource(lessResourceReference);
}
}
}
}
use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.
the class SkinListener method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
XWikiDocument document = (XWikiDocument) source;
List<BaseObject> skinObjects = document.getXObjects(SKIN_CLASS);
if (skinObjects != null && !skinObjects.isEmpty()) {
clearCacheFromSkin(document);
return;
}
}
Aggregations