Search in sources :

Example 6 with MergeResult

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

the class XWikiDocumentMergeTest method testMergeAttachmentEqualsDeletedCurrent.

@Test
public void testMergeAttachmentEqualsDeletedCurrent() throws Exception {
    XWikiAttachment attachment = new XWikiAttachment();
    attachment.setContent(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    attachment.setLongSize(10);
    attachment.setFilename("file");
    this.previousDocument.addAttachment(attachment);
    this.nextDocument.addAttachment((XWikiAttachment) attachment.clone());
    MergeResult result = merge();
    Assert.assertFalse(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) Test(org.junit.Test)

Example 7 with MergeResult

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

the class XWikiDocumentMergeTest method testMergeAttachmentEqualsAddedCurrent.

@Test
public void testMergeAttachmentEqualsAddedCurrent() throws Exception {
    XWikiAttachment attachment = new XWikiAttachment();
    attachment.setContent(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    attachment.setLongSize(10);
    attachment.setFilename("file");
    this.currentDocument.addAttachment(attachment);
    MergeResult result = merge();
    Assert.assertFalse(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) Test(org.junit.Test)

Example 8 with MergeResult

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

the class XWikiDocumentMergeTest method merge.

private MergeResult merge() throws Exception {
    MergeResult result = this.currentDocument.merge(this.previousDocument, this.nextDocument, this.configuration, this.oldcore.getXWikiContext());
    List<LogEvent> exception = result.getLog().getLogs(LogLevel.ERROR);
    if (!exception.isEmpty()) {
        throw new MergeException(exception.get(0).getFormattedMessage(), exception.get(0).getThrowable());
    }
    return result;
}
Also used : LogEvent(org.xwiki.logging.event.LogEvent) MergeException(com.xpn.xwiki.doc.merge.MergeException) MergeResult(com.xpn.xwiki.doc.merge.MergeResult)

Example 9 with MergeResult

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

the class MergeUtilsTest method mergeObjectSimple.

@Test
public void mergeObjectSimple() {
    MergeResult result = new MergeResult();
    assertEquals("new", MergeUtils.mergeOject("old", "new", "old", result));
    assertTrue(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) Test(org.junit.Test)

Example 10 with MergeResult

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

the class MergeUtilsTest method mergeWhenCurrentStringDoesntEndWithNewLine.

@Test
public void mergeWhenCurrentStringDoesntEndWithNewLine() {
    MergeResult result = new MergeResult();
    assertEquals("content", MergeUtils.mergeLines("content", "content", "content", result));
    assertFalse(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) 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