Search in sources :

Example 11 with MergeResult

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

the class MergeUtilsTest method mergeObjectAlreadyDone.

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

Example 12 with MergeResult

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

the class MergeUtilsTest method mergeWhenCurrentStringEndsWithNewLine.

@Test
public void mergeWhenCurrentStringEndsWithNewLine() {
    MergeResult result = new MergeResult();
    assertEquals("content\n", MergeUtils.mergeLines("content\n", "content\n", "content\n", result));
    assertFalse(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) Test(org.junit.Test)

Example 13 with MergeResult

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

the class MergeUtilsTest method mergeWhenDifferences.

@Test
public void mergeWhenDifferences() {
    MergeResult result = new MergeResult();
    assertEquals("content\n", MergeUtils.mergeLines("content", "content\n", "content", result));
    assertTrue(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) Test(org.junit.Test)

Example 14 with MergeResult

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

the class XWikiDocumentMergeTest method testMergeAttachmentModified.

@Test
public void testMergeAttachmentModified() 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);
    this.previousDocument.addAttachment((XWikiAttachment) attachment.clone());
    attachment = (XWikiAttachment) attachment.clone();
    attachment.setContent(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    attachment.setLongSize(9);
    this.nextDocument.addAttachment(attachment);
    MergeResult result = merge();
    Assert.assertTrue(result.isModified());
    XWikiAttachment newAttachment = this.currentDocument.getAttachment("file");
    Assert.assertNotNull(newAttachment);
    Assert.assertEquals(9, newAttachment.getLongSize());
    Assert.assertArrayEquals(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, newAttachment.getContent(null));
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) Test(org.junit.Test)

Example 15 with MergeResult

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

the class XWikiDocumentMergeTest method testMergeAttachmentEquals.

@Test
public void testMergeAttachmentEquals() 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());
    this.currentDocument.addAttachment((XWikiAttachment) attachment.clone());
    MergeResult result = merge();
    Assert.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