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());
}
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());
}
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());
}
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));
}
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());
}
Aggregations