Search in sources :

Example 21 with MergeResult

use of com.xpn.xwiki.doc.merge.MergeResult in project xwiki-platform by xwiki.

the class BaseObjectTest method testMerge.

@Test
public void testMerge() {
    BaseObject previousObject = new BaseObject();
    previousObject.setStringValue("str", "value");
    BaseObject nextObject = new BaseObject();
    nextObject.setStringValue("str", "newvalue");
    BaseObject currentObject = new BaseObject();
    currentObject.setStringValue("str", "value");
    MergeConfiguration mergeConfiguration = new MergeConfiguration();
    MergeResult mergeResult = new MergeResult();
    currentObject.merge(previousObject, nextObject, mergeConfiguration, this.oldcore.getXWikiContext(), mergeResult);
    List<LogEvent> errors = mergeResult.getLog().getLogsFrom(LogLevel.WARN);
    if (errors.size() > 0) {
        Assert.fail("Found error or warning during the merge (" + errors.get(0) + ")");
    }
    Assert.assertEquals("newvalue", currentObject.getStringValue("str"));
}
Also used : LogEvent(org.xwiki.logging.event.LogEvent) MergeResult(com.xpn.xwiki.doc.merge.MergeResult) MergeConfiguration(com.xpn.xwiki.doc.merge.MergeConfiguration) Test(org.junit.Test)

Aggregations

MergeResult (com.xpn.xwiki.doc.merge.MergeResult)21 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)4 MergeConfiguration (com.xpn.xwiki.doc.merge.MergeConfiguration)3 XWikiContext (com.xpn.xwiki.XWikiContext)2 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)2 LogEvent (org.xwiki.logging.event.LogEvent)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiException (com.xpn.xwiki.XWikiException)1 MergeException (com.xpn.xwiki.doc.merge.MergeException)1 XWikiAttachmentList (com.xpn.xwiki.internal.doc.XWikiAttachmentList)1 BaseObject (com.xpn.xwiki.objects.BaseObject)1 ObjectDiff (com.xpn.xwiki.objects.ObjectDiff)1 PropertyInterface (com.xpn.xwiki.objects.PropertyInterface)1 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)1 List (java.util.List)1 Before (org.junit.Before)1 Execution (org.xwiki.context.Execution)1 ExecutionContext (org.xwiki.context.ExecutionContext)1 PackageConfiguration (org.xwiki.extension.xar.internal.handler.packager.PackageConfiguration)1