Search in sources :

Example 66 with BaseObject

use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.

the class PropertyChangedRuleTest method testVerifyNoObjectOfClass.

public void testVerifyNoObjectOfClass() 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.otherClassName, this.context);
    BaseObject newObj = newDoc.newObject(this.otherClassName, this.context);
    newObj.setStringValue(this.testPropertyName, "value1");
    oldObj.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);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 67 with BaseObject

use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.

the class PropertyChangedRuleTest method testVerifyMultipleObjectsOtherObjectDeleted.

public void testVerifyMultipleObjectsOtherObjectDeleted() 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 oldObjOtherClass = oldDoc.newObject(this.otherClassName, this.context);
    oldObjOtherClass.setStringValue(this.testPropertyName, "value2");
    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);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 68 with BaseObject

use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.

the class PropertyChangedRuleTest method testVerifyMultipleObjectsOtherObjectAdded.

public void testVerifyMultipleObjectsOtherObjectAdded() 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 newObjOtherClass = newDoc.newObject(this.otherClassName, this.context);
    newObjOtherClass.setStringValue(this.testPropertyName, "value2");
    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);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 69 with BaseObject

use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.

the class PropertyChangedRuleTest method testVerifyMultipleObjectsClassChanged.

public void testVerifyMultipleObjectsClassChanged() 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 newObjOtherClass = newDoc.newObject(this.otherClassName, this.context);
    newObjOtherClass.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);
    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);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 70 with BaseObject

use of com.xpn.xwiki.objects.BaseObject in project xwiki-platform by xwiki.

the class PropertyChangedRuleTest method testVerifyMultipleObjectsXWikiClassNotChanged.

public void testVerifyMultipleObjectsXWikiClassNotChanged() throws XWikiException {
    XWikiDocument newDoc = this.classDoc.clone();
    XWikiDocument oldDoc = this.classDoc.clone();
    BaseObject otherOldObject = oldDoc.newObject(this.otherClassName, this.context);
    BaseObject oldObj = oldDoc.newObject(this.testClassName, this.context);
    BaseObject otherNewObject = newDoc.newObject(this.otherClassName, this.context);
    BaseObject newObj = newDoc.newObject(this.testClassName, this.context);
    otherOldObject.setStringValue(this.testPropertyName, "value1");
    oldObj.setStringValue(this.testPropertyName, "value");
    otherNewObject.setStringValue(this.testPropertyName, "value1");
    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);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) BaseObject(com.xpn.xwiki.objects.BaseObject)

Aggregations

BaseObject (com.xpn.xwiki.objects.BaseObject)484 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)309 DocumentReference (org.xwiki.model.reference.DocumentReference)225 Test (org.junit.Test)137 XWikiException (com.xpn.xwiki.XWikiException)102 XWikiContext (com.xpn.xwiki.XWikiContext)99 ArrayList (java.util.ArrayList)92 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)69 EntityReference (org.xwiki.model.reference.EntityReference)42 XWiki (com.xpn.xwiki.XWiki)41 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)40 List (java.util.List)30 Date (java.util.Date)24 BaseProperty (com.xpn.xwiki.objects.BaseProperty)23 Document (com.xpn.xwiki.api.Document)22 HashMap (java.util.HashMap)21 QueryException (org.xwiki.query.QueryException)18 AbstractComponentTest (com.celements.common.test.AbstractComponentTest)16 IOException (java.io.IOException)16 Vector (java.util.Vector)16