added drag & drop (merge update) simple test
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/dragdrop/final.intent b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/dragdrop/final.intent
new file mode 100644
index 0000000..c4e0400
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/dragdrop/final.intent
@@ -0,0 +1,71 @@
+Document {

+	Chapter QuickFixes {

+		Tests the creation of modeling units by application of quick fixes.

+

+		Section Modeling Unit {

+			This section contains the main modeling unit.

+			

+			@M

+				Resource testResource {

+					URI = "platform:/resource/intentProject/test.ecore";

+					content += testPackage;

+				}

+				new EPackage testPackage {

+					name = "testPackage";

+					nsURI = "testPackageURI";

+					nsPrefix = "testPackagePrefix";

+				}

+				testPackage {

+					eClassifiers += new EClass REF0 {

+						name = "A";

+						eStructuralFeatures += new EAttribute REF1 {

+							name = "a1";

+							lowerBound = "1";

+							upperBound = "-1";

+							eType = EInt;

+						};

+						eStructuralFeatures += new EAttribute REF2 {

+							name = "a2";

+							lowerBound = "1";

+							upperBound = "4";

+							eType = EString;

+						};

+						eStructuralFeatures += new EAttribute REF3 {

+							name = "a3";

+							upperBound = "-1";

+							eType = EBoolean;

+						};

+					};

+				}

+				testPackage {

+					eSubpackages += new EPackage REF4 {

+						name = "sub";

+						nsURI = "sub";

+						nsPrefix = "sub";

+						eClassifiers += new EClass REF5 {

+							name = "B";

+							eSuperTypes += REF0;

+							eSuperTypes += REF6;

+						};

+						eClassifiers += new EClass REF7 {

+							name = "C";

+							eStructuralFeatures += new EReference REF8 {

+								name = "ref";

+								eType = REF5;

+							};

+						};

+						eClassifiers += new EClass REF6 {

+							name = "D";

+							abstract = "true";

+							eStructuralFeatures += new EAttribute REF9 {

+								name = "name";

+								eType = EString;

+							};

+						};

+					};

+				}

+			M@

+			

+		}

+	}

+}

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/dragdrop/intentProject.zip b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/dragdrop/intentProject.zip
new file mode 100644
index 0000000..59d0a1a
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/dragdrop/intentProject.zip
Binary files differ
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/initial.intent b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/initial.intent
deleted file mode 100644
index 937ab6a..0000000
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/initial.intent
+++ /dev/null
@@ -1,22 +0,0 @@
-Document {

-	Chapter QuickFixes {

-		Tests the creation of modeling units by application of quick fixes.

-

-		Section Modeling Unit {

-			This section contains the main modeling unit.

-			

-			@M

-				Resource testResource {

-					URI = "platform:/resource/intentProject/test.ecore";

-					content += testPackage;

-				}

-				new EPackage testPackage {

-					name = "testPackage";

-					nsURI = "testPackageURI";

-					nsPrefix = "testPackagePrefix";

-				}

-			M@

-			

-		}

-	}

-}

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java
index b9cfdd5..d523407 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java
@@ -29,6 +29,7 @@
 import org.eclipse.mylyn.docs.intent.client.ui.test.unit.scenario.IntentAbstractResourceTest;
 import org.eclipse.mylyn.docs.intent.client.ui.test.unit.scenario.IntentDocumentationUpdateDoesNotCauseResolvingIssuesTest;
 import org.eclipse.mylyn.docs.intent.client.ui.test.unit.scenario.IntentProjectReopeningTest;
+import org.eclipse.mylyn.docs.intent.client.ui.test.unit.update.DragAndDropTest;
 import org.eclipse.mylyn.docs.intent.client.ui.test.unit.update.QuickFixTest;
 
 /**
@@ -105,7 +106,7 @@
 		// Updates tests
 		final TestSuite updatesSuite = new TestSuite("Modeling Unit update tests");
 		updatesSuite.addTestSuite(QuickFixTest.class);
-		// updatesSuite.addTestSuite(DragAndDropTest.class);
+		updatesSuite.addTestSuite(DragAndDropTest.class);
 		uiTestSuite.addTest(updatesSuite);
 
 		return suite;
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/AbstractUpdateTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/AbstractUpdateTest.java
new file mode 100644
index 0000000..1f90286
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/AbstractUpdateTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************

+ * Copyright (c) 2012 Obeo.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ * 

+ * Contributors:

+ *     Obeo - initial API and implementation

+ *******************************************************************************/

+package org.eclipse.mylyn.docs.intent.client.ui.test.unit.update;

+

+import java.io.File;

+import java.io.IOException;

+import java.util.List;

+

+import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditor;

+import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument;

+import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotation;

+import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotationMessageType;

+import org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractZipBasedTest;

+import org.eclipse.mylyn.docs.intent.client.ui.test.util.AnnotationUtils;

+import org.eclipse.mylyn.docs.intent.parser.modelingunit.test.utils.FileToStringConverter;

+

+/**

+ * Abstract modeling unit updates test.

+ * 

+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>

+ */

+public class AbstractUpdateTest extends AbstractZipBasedTest {

+

+	protected IntentEditor editor;

+

+	protected IntentEditorDocument document;

+

+	/**

+	 * Constructor.

+	 */

+	public AbstractUpdateTest(String intentProjectArchivePath) {

+		super(intentProjectArchivePath, "intentProject");

+	}

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.mylyn.docs.intent.client.ui.test.unit.demo.AbstractDemoTest#setUp()

+	 */

+	@Override

+	protected void setUp() throws Exception {

+		super.setUp();

+		editor = openIntentEditor();

+		document = (IntentEditorDocument)editor.getDocumentProvider().getDocument(editor.getEditorInput());

+	}

+

+	/**

+	 * Checks whether the doc is valid or not.

+	 * 

+	 * @throws IOException

+	 *             the the final document cannot be read.

+	 */

+	protected void checkDocumentValidity(String finalDocPath) throws IOException {

+		// check that the document is valid

+		List<IntentAnnotation> annotations = AnnotationUtils.getIntentAnnotations(editor,

+				IntentAnnotationMessageType.SYNC_WARNING);

+		if (!annotations.isEmpty()) {

+			AnnotationUtils.displayAnnotations(editor);

+		}

+		assertEquals(FileToStringConverter.getFileAsString(new File(finalDocPath)), document.get());

+		assertTrue(annotations.isEmpty());

+	}

+

+}

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/DragAndDropTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/DragAndDropTest.java
index a5836f5..104acc9 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/DragAndDropTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/DragAndDropTest.java
@@ -10,42 +10,27 @@
  *******************************************************************************/

 package org.eclipse.mylyn.docs.intent.client.ui.test.unit.update;

 

-import java.io.File;

 import java.io.IOException;

-import java.util.Collections;

-import java.util.List;

 

 import org.eclipse.core.runtime.NullProgressMonitor;

 import org.eclipse.emf.common.util.URI;

 import org.eclipse.emf.ecore.EObject;

 import org.eclipse.emf.ecore.resource.Resource;

 import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

-import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditor;

-import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument;

-import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotation;

-import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotationMessageType;

-import org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractZipBasedTest;

-import org.eclipse.mylyn.docs.intent.client.ui.test.util.AnnotationUtils;

 import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnit;

 import org.eclipse.mylyn.docs.intent.modelingunit.update.MergeUpdater;

-import org.eclipse.mylyn.docs.intent.parser.modelingunit.test.utils.FileToStringConverter;

+import org.eclipse.mylyn.docs.intent.serializer.IntentSerializer;

 

 /**

  * Tests the drag & drop updates.

  * 

  * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>

  */

-public class DragAndDropTest extends AbstractZipBasedTest {

+public class DragAndDropTest extends AbstractUpdateTest {

 

-	private static final String INTENT_PROJECT_ARCHIVE = "data/unit/documents/quickfixes/intentProject.zip";

+	private static final String INTENT_PROJECT_ARCHIVE = "data/unit/documents/dragdrop/intentProject.zip";

 

-	private static final String FINAL_INTENT_DOC = "data/unit/documents/quickfixes/final.intent";

-

-	private static final String INITIAL_INTENT_DOC = "data/unit/documents/quickfixes/initial.intent";

-

-	private IntentEditor editor;

-

-	private IntentEditorDocument document;

+	private static final String FINAL_INTENT_DOC = "data/unit/documents/dragdrop/final.intent";

 

 	private ModelingUnit modelingUnit;

 

@@ -53,7 +38,7 @@
 	 * Constructor.

 	 */

 	public DragAndDropTest() {

-		super(INTENT_PROJECT_ARCHIVE, "intentProject");

+		super(INTENT_PROJECT_ARCHIVE);

 	}

 

 	/**

@@ -64,74 +49,27 @@
 	@Override

 	protected void setUp() throws Exception {

 		super.setUp();

-		editor = openIntentEditor();

-		document = (IntentEditorDocument)editor.getDocumentProvider().getDocument(editor.getEditorInput());

-		modelingUnit = (ModelingUnit)getIntentSection(1, 1).getModelingUnits().get(0);

+		modelingUnit = getIntentSection(1, 1).getModelingUnits().get(0);

 	}

 

 	/**

-	 * Test that the model is completed by additions.

+	 * Test that the model is completed by addition of several elements.

 	 * 

 	 * @throws IOException

 	 *             if comparison fails

 	 */

 	public void testDragAndDrop() throws IOException {

-		Resource resource = new ResourceSetImpl().getResource(

-				URI.createURI("platform:/resource/intentProject/test.ecore"), true);

-		EObject root = resource.getContents().get(0);

-		for (EObject element : root.eContents()) {

-			new MergeUpdater(repositoryAdapter).create(modelingUnit, Collections.singletonList(element));

-		}

-

-		document.reloadFromAST();

-		editor.doSave(new NullProgressMonitor());

-		waitForCompiler();

-		waitForSynchronizer();

-

-		checkDocumentValidity();

-	}

-

-	/**

-	 * Test that the model is completed by on addition of several elements.

-	 * 

-	 * @throws IOException

-	 *             if comparison fails

-	 */

-	public void testDragAndDropAllInOne() throws IOException {

-		// reset changes

-		document.set(FileToStringConverter.getFileAsString(new File(INITIAL_INTENT_DOC)));

-		editor.doSave(new NullProgressMonitor());

-		waitForCompiler();

-		waitForSynchronizer();

-		modelingUnit = (ModelingUnit)getIntentSection(1, 1).getModelingUnits().get(0);

-

+		// add all missing elements at once

 		Resource resource = new ResourceSetImpl().getResource(

 				URI.createURI("platform:/resource/intentProject/test.ecore"), true);

 		EObject root = resource.getContents().get(0);

 		new MergeUpdater(repositoryAdapter).create(modelingUnit, root.eContents());

-

-		document.reloadFromAST();

+		document.set(new IntentSerializer().serialize((EObject)document.getAST()));

 		editor.doSave(new NullProgressMonitor());

 		waitForCompiler();

 		waitForSynchronizer();

 

-		checkDocumentValidity();

-	}

-

-	/**

-	 * Checks whether the doc is valid or not.

-	 * 

-	 * @throws IOException

-	 *             the the final document cannot be read.

-	 */

-	private void checkDocumentValidity() throws IOException {

-		// check that the document is valid

-		List<IntentAnnotation> annotations = AnnotationUtils.getIntentAnnotations(editor,

-				IntentAnnotationMessageType.SYNC_WARNING);

-		if (!annotations.isEmpty()) {

-			AnnotationUtils.displayAnnotations(editor);

-		}

-		assertEquals(FileToStringConverter.getFileAsString(new File(FINAL_INTENT_DOC)), document.get());

-		assertTrue(annotations.isEmpty());

+		// check result

+		checkDocumentValidity(FINAL_INTENT_DOC);

 	}

 }

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/QuickFixTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/QuickFixTest.java
index 5af5779..11b68a6 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/QuickFixTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/QuickFixTest.java
@@ -12,14 +12,10 @@
 

 import java.io.File;

 import java.io.IOException;

-import java.util.List;

 

 import org.eclipse.core.runtime.NullProgressMonitor;

-import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditor;

-import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument;

 import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotation;

 import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotationMessageType;

-import org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractZipBasedTest;

 import org.eclipse.mylyn.docs.intent.client.ui.test.util.AnnotationUtils;

 import org.eclipse.mylyn.docs.intent.parser.modelingunit.test.utils.FileToStringConverter;

 

@@ -28,7 +24,7 @@
  * 

  * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>

  */

-public class QuickFixTest extends AbstractZipBasedTest {

+public class QuickFixTest extends AbstractUpdateTest {

 

 	private static final String INTENT_PROJECT_ARCHIVE = "data/unit/documents/quickfixes/intentProject.zip";

 

@@ -36,27 +32,11 @@
 

 	private static final String MODIFIED_INTENT_DOC = "data/unit/documents/quickfixes/modifications.intent";

 

-	private IntentEditor editor;

-

-	private IntentEditorDocument document;

-

 	/**

 	 * Constructor.

 	 */

 	public QuickFixTest() {

-		super(INTENT_PROJECT_ARCHIVE, "intentProject");

-	}

-

-	/**

-	 * {@inheritDoc}

-	 * 

-	 * @see org.eclipse.mylyn.docs.intent.client.ui.test.unit.demo.AbstractDemoTest#setUp()

-	 */

-	@Override

-	protected void setUp() throws Exception {

-		super.setUp();

-		editor = openIntentEditor();

-		document = (IntentEditorDocument)editor.getDocumentProvider().getDocument(editor.getEditorInput());

+		super(INTENT_PROJECT_ARCHIVE);

 	}

 

 	/**

@@ -71,7 +51,7 @@
 		fixIssue("The EClass E is defined in the <b>Current Document</b> model<br/>but not in the <b>Working Copy</b> model.");

 		fixIssue("The EPackage sub is defined in the <b>Working Copy</b> model<br/>but not in the <b>Current Document</b> model.");

 

-		checkDocumentValidity();

+		checkDocumentValidity(FINAL_INTENT_DOC);

 	}

 

 	/**

@@ -94,7 +74,7 @@
 		fixIssue("D has been removed from reference eSuperTypes : EClass in B -> A, C");

 		fixIssue("C has been added to reference eSuperTypes : EClass in B -> A, D");

 

-		checkDocumentValidity();

+		checkDocumentValidity(FINAL_INTENT_DOC);

 	}

 

 	/**

@@ -109,7 +89,6 @@
 			if (annotation.getText().equals(message)) {

 				AnnotationUtils.applyAnnotationFix(document, repositoryAdapter, annotation, 1);

 				editor.doSave(new NullProgressMonitor());

-				// and wait the synchronizer and the compiler to be notified

 				waitForCompiler();

 				waitForSynchronizer();

 				return;

@@ -119,20 +98,4 @@
 		fail("Annotation not found: " + message);

 	}

 

-	/**

-	 * Checks whether the doc is valid or not.

-	 * 

-	 * @throws IOException

-	 *             the the final document cannot be read.

-	 */

-	private void checkDocumentValidity() throws IOException {

-		// check that the document is valid

-		List<IntentAnnotation> annotations = AnnotationUtils.getIntentAnnotations(editor,

-				IntentAnnotationMessageType.SYNC_WARNING);

-		if (!annotations.isEmpty()) {

-			AnnotationUtils.displayAnnotations(editor);

-		}

-		assertEquals(FileToStringConverter.getFileAsString(new File(FINAL_INTENT_DOC)), document.get());

-		assertTrue(annotations.isEmpty());

-	}

 }