@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); }
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); } }
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); } } }
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); } }  }
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); }
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);  }