Search in sources :

Example 16 with MergeResult

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

the class XWikiDocumentMergeTest method testMergeAttachmentEqualsModifiedCurrent.

@Test
public void testMergeAttachmentEqualsModifiedCurrent() 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());
    attachment = (XWikiAttachment) attachment.clone();
    attachment.setContent(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    attachment.setLongSize(9);
    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 17 with MergeResult

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

the class MergeUtilsTest method mergeListAlreadyDone.

@Test
public void mergeListAlreadyDone() {
    MergeResult result = new MergeResult();
    List<String> current = new ArrayList<String>(Arrays.asList("new1", "new2"));
    MergeUtils.mergeList(Arrays.asList("old1", "old2"), Arrays.asList("new1", "new2"), current, result);
    assertEquals(Arrays.asList("new1", "new2"), current);
    assertEquals(Arrays.asList("new1", "new2"), current);
    assertFalse(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 18 with MergeResult

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

the class MergeUtilsTest method mergeObjectWhileModified.

@Test
public void mergeObjectWhileModified() {
    MergeResult result = new MergeResult();
    assertEquals("old modified", MergeUtils.mergeOject("old", "new", "old modified", result));
    assertFalse(result.isModified());
    // conflicts are flagged as errors in the log
    assertFalse(result.getLog().getLogs(LogLevel.ERROR).isEmpty());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) Test(org.junit.Test)

Example 19 with MergeResult

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

the class MergeUtilsTest method mergeListSimple.

@Test
public void mergeListSimple() {
    MergeResult result = new MergeResult();
    List<String> current = new ArrayList<String>(Arrays.asList("old1", "old2"));
    MergeUtils.mergeList(Arrays.asList("old1", "old2"), Arrays.asList("new1", "new2"), current, result);
    assertEquals(Arrays.asList("new1", "new2"), current);
    assertTrue(result.isModified());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with MergeResult

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

the class MergeUtilsTest method mergeListWhileModified.

@Test
public void mergeListWhileModified() {
    MergeResult result = new MergeResult();
    List<String> current = new ArrayList<String>(Arrays.asList("old modified1", "old modified2"));
    MergeUtils.mergeList(Arrays.asList("old1", "old2"), Arrays.asList("new1", "new2"), current, result);
    assertEquals(Arrays.asList("old modified1", "old modified2"), current);
    assertFalse(result.isModified());
    // conflicts are flagged as errors in the log
    assertFalse(result.getLog().getLogs(LogLevel.ERROR).isEmpty());
}
Also used : MergeResult(com.xpn.xwiki.doc.merge.MergeResult) ArrayList(java.util.ArrayList) 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