### Question:
DocumentMergeImporter { public void importDocument(String comment, XWikiDocument previousDocument, XWikiDocument currentDocument, XWikiDocument nextDocument, PackageConfiguration configuration) throws Exception { XarEntryType type = this.typeResolver.getDefault(); XWikiDocumentMerger merger = this.defaultMerger; ComponentManager componentManager = this.componentManagerProvider.get(); XarEntry xarEntry = configuration.getXarEntry(); if (xarEntry != null) { String reference = "document:" + this.referenceSerializer.serialize(xarEntry); XarEntryType configuredType = this.typeResolver.resolve(xarEntry, false); if (type != null && componentManager.hasComponent(XWikiDocumentMerger.class, type.getName())) { merger = componentManager.getInstance(XWikiDocumentMerger.class, type.getName()); } else if (componentManager.hasComponent(XWikiDocumentMerger.class, reference)) { merger = componentManager.getInstance(XWikiDocumentMerger.class, reference); } if (configuredType != null) { type = configuredType; } } XWikiDocumentMergerConfiguration mergeConfiguration = new XWikiDocumentMergerConfiguration(); mergeConfiguration.setAuthorReference(configuration.getUserReference()); mergeConfiguration.setConflictActions(configuration.getConflictActions()); mergeConfiguration.setType(getUpgradeType(type)); XWikiDocument documentToSave = merger.merge(currentDocument != null && !currentDocument.isNew() ? currentDocument : null, previousDocument, nextDocument, mergeConfiguration); if (documentToSave != null && documentToSave != currentDocument) { saveDocument(documentToSave, comment, configuration); } }  void importDocument(String comment, XWikiDocument previousDocument, XWikiDocument currentDocument,
        XWikiDocument nextDocument, PackageConfiguration configuration);  }### Answer:
@Test public void testMergeNoChange() throws ComponentLookupException, Exception { this.mergeResult.setModified(false); this.documentMergeImporter.importDocument("comment", this.previousDocument, this.currentDocument, this.nextDocument, this.configuration); verify(this.xcontext, times(1)).getUserReference(); verifyNoMoreInteractions(this.xcontext); verifyZeroInteractions(this.xwiki); }
@Test public void testMergeNoCurrent() throws ComponentLookupException, Exception { this.documentMergeImporter.importDocument("comment", this.previousDocument, null, this.nextDocument, this.configuration); verifyZeroInteractions(this.xwiki, this.xcontext); }
@Test public void testMergeInteractiveChangesConflictAnswerCurrent() throws ComponentLookupException, Exception { setInteractive(); this.configuration.setUser(new DocumentReference("wiki", "space", "user")); this.mergeResult.setModified(true); this.mergeResult.getLog().error("error"); answerGlobalAction(GlobalAction.CURRENT, false); this.documentMergeImporter.importDocument("comment", this.previousDocument, this.currentDocument, this.nextDocument, this.configuration); this.documentMergeImporter.importDocument("comment", this.previousDocument, this.currentDocument, this.nextDocument, this.configuration); verify(this.jobStatus, times(2)).ask(any()); verify(this.xcontext, times(2)).getUserReference(); verifyNoMoreInteractions(this.xcontext); verifyZeroInteractions(this.xwiki); }
@Test public void testNoMergeNoChange() throws ComponentLookupException, Exception { when(this.currentDocument.equalsData(same(this.nextDocument))).thenReturn(true); this.documentMergeImporter.importDocument("comment", null, this.currentDocument, this.nextDocument, this.configuration); verifyZeroInteractions(this.xwiki, this.xcontext); }