Search in sources :

Example 71 with BaseObject

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

the class PropertyChangedRuleTest method testVerifyMultipleObjectsObjectDeleted.

public void testVerifyMultipleObjectsObjectDeleted() 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 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 72 with BaseObject

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

the class PropertyChangedRuleTest method testVerifyMultipleObjectsMultipleXWikiClassNotChanged.

public void testVerifyMultipleObjectsMultipleXWikiClassNotChanged() 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 oldObj2 = oldDoc.newObject(this.testClassName, this.context);
    BaseObject otherNewObject = newDoc.newObject(this.otherClassName, this.context);
    BaseObject newObj = newDoc.newObject(this.testClassName, this.context);
    BaseObject newObj2 = newDoc.newObject(this.testClassName, this.context);
    otherOldObject.setStringValue(this.testPropertyName, "value1");
    oldObj.setStringValue(this.testPropertyName, "value1");
    oldObj2.setStringValue(this.testPropertyName, "value2");
    otherNewObject.setStringValue(this.testPropertyName, "value1");
    newObj.setStringValue(this.testPropertyName, "value1");
    newObj2.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) BaseObject(com.xpn.xwiki.objects.BaseObject)

Example 73 with BaseObject

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

the class PropertyChangedRuleTest method testVerifyObjectDeleted.

public void testVerifyObjectDeleted() 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);
    oldObj.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 74 with BaseObject

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

the class PropertyChangedRuleTest method testVerifyMultipleObjectsObjectAdded.

public void testVerifyMultipleObjectsObjectAdded() 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");
    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 75 with BaseObject

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

the class PropertyChangedRuleTest method testVerifyMultipleObjectsXWikiClassChanged.

public void testVerifyMultipleObjectsXWikiClassChanged() 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, "value1");
    otherNewObject.setStringValue(this.testPropertyName, "value1");
    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);
}
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