added quick fix test
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/UpdateModelingUnitFix.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/UpdateModelingUnitFix.java
index 568074d..e6fdc39 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/UpdateModelingUnitFix.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/UpdateModelingUnitFix.java
@@ -54,8 +54,8 @@
 
 		if (modelingUnit != null) {
 			SyncStatusUpdater updater = new SyncStatusUpdater(repositoryAdapter);
-			updater.fixSynchronizationStatus((ModelingUnit)modelingUnit,
-					(SynchronizerCompilationStatus)syncAnnotation.getCompilationStatus());
+			updater.fixSynchronizationStatus((SynchronizerCompilationStatus)syncAnnotation
+					.getCompilationStatus());
 			((IntentEditorDocument)document).reloadFromAST();
 		}
 	}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java
index 1f93057..4999617 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java
@@ -34,7 +34,6 @@
 import org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.ContributionInstruction;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.InstanciationInstruction;
-import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnit;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnitPackage;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.StructuralFeatureAffectation;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.ValueForStructuralFeature;
@@ -72,24 +71,21 @@
 	/**
 	 * Fixes the given statuses by updating the given modeling unit.
 	 * 
-	 * @param modelingUnit
-	 *            the modeling unit to update
 	 * @param statusToFix
 	 *            the statuses to fix
 	 */
-	public void fixSynchronizationStatus(final ModelingUnit modelingUnit,
-			final SynchronizerCompilationStatus... statusToFix) {
+	public void fixSynchronizationStatus(final SynchronizerCompilationStatus... statusToFix) {
 		repositoryAdapter.execute(new IntentCommand() {
 			public void execute() {
 				for (SynchronizerCompilationStatus status : statusToFix) {
 					initMatch(status);
 					switch (status.eClass().getClassifierID()) {
 						case CompilerPackage.MODEL_ELEMENT_CHANGE_STATUS:
-							fixModelElementChange(modelingUnit, (ModelElementChangeStatus)status);
+							fixModelElementChange((ModelElementChangeStatus)status);
 							break;
 						case CompilerPackage.ATTRIBUTE_CHANGE_STATUS:
 						case CompilerPackage.REFERENCE_CHANGE_STATUS:
-							fixStructuralFeatureChange(modelingUnit, (StructuralFeatureChangeStatus)status);
+							fixStructuralFeatureChange((StructuralFeatureChangeStatus)status);
 							break;
 						default:
 							break;
@@ -109,12 +105,10 @@
 	/**
 	 * Fixes the given statuses by updating the given modeling unit.
 	 * 
-	 * @param modelingUnit
-	 *            the modeling unit to update
 	 * @param status
 	 *            the status to fix
 	 */
-	private void fixModelElementChange(ModelingUnit modelingUnit, ModelElementChangeStatus status) {
+	private void fixModelElementChange(ModelElementChangeStatus status) {
 		IntentGenericElement target = status.getTarget();
 		switch (status.getChangeState().getValue()) {
 			case SynchronizerChangeState.WORKING_COPY_TARGET_VALUE:
@@ -140,7 +134,9 @@
 
 					StructuralFeatureAffectation affectation = generateAffectation(
 							workingCopyObject.eContainingFeature(), workingCopyObject);
-					instanciation.getStructuralFeatures().add(affectation);
+					if (affectation != null) {
+						instanciation.getStructuralFeatures().add(affectation);
+					}
 				}
 				break;
 			case SynchronizerChangeState.COMPILED_TARGET_VALUE:
@@ -161,14 +157,12 @@
 	}
 
 	/**
-	 * Fixes the given statuses by updating the given modeling unit.
+	 * Fixes the given statuses.
 	 * 
-	 * @param modelingUnit
-	 *            the modeling unit to update
 	 * @param status
 	 *            the status to fix
 	 */
-	private void fixStructuralFeatureChange(ModelingUnit modelingUnit, StructuralFeatureChangeStatus status) {
+	private void fixStructuralFeatureChange(StructuralFeatureChangeStatus status) {
 		EObject element = getWorkingCopyEObject(status.getWorkingCopyElementURIFragment());
 		EStructuralFeature feature = element.eClass().getEStructuralFeature(status.getFeatureName());
 		Object newValue = null;
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF
index 085b57b..55c1b5f 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF
@@ -22,4 +22,5 @@
  com.google.guava,
  org.eclipse.emf.compare.match;bundle-version="[1.2.0,2.0.0)",
  org.eclipse.mylyn.docs.intent.retro;bundle-version="0.7.0",
- org.eclipse.mylyn.docs.intent.compare;bundle-version="0.7.0"
+ org.eclipse.mylyn.docs.intent.compare;bundle-version="0.7.0",
+ org.eclipse.mylyn.docs.intent.modelingunit.update;bundle-version="0.7.0"
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/final.intent b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/final.intent
new file mode 100644
index 0000000..bb4a4c9
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/final.intent
@@ -0,0 +1,58 @@
+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";

+					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;

+						};

+					};

+					eSubpackages += new EPackage REF4 {

+						name = "sub";

+						nsURI = "sub";

+						nsPrefix = "sub";

+						eClassifiers += new EClass REF5 {

+							name = "B";

+							eSuperTypes += REF0;

+						};

+						eClassifiers += new EClass REF6 {

+							name = "C";

+							eStructuralFeatures += new EReference REF7 {

+								name = "ref";

+								eType = REF5;

+							};

+						};

+					};

+				}

+			M@

+			

+		}

+	}

+}

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/intentProject.zip b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/intentProject.zip
new file mode 100644
index 0000000..bbf4888
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/quickfixes/intentProject.zip
Binary files differ
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 d565c48..46b8b78 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.QuickFixTest;
 
 /**
  * This suite will launch all the tests relative to the UI behavior.
@@ -101,6 +102,11 @@
 		demoSuite.addTestSuite(JavaTest.class);
 		// uiTestSuite.addTest(demoSuite);
 
+		// Updates tests
+		final TestSuite updatesSuite = new TestSuite("Modeling Unit update tests");
+		updatesSuite.addTestSuite(QuickFixTest.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/demo/AbstractDemoTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/demo/AbstractDemoTest.java
index e7df745..6246c08 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/demo/AbstractDemoTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/demo/AbstractDemoTest.java
@@ -10,28 +10,14 @@
  *******************************************************************************/

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

 

-import java.math.BigInteger;

-

-import org.eclipse.core.resources.ResourcesPlugin;

-import org.eclipse.core.runtime.CoreException;

-import org.eclipse.core.runtime.NullProgressMonitor;

-import org.eclipse.emf.common.util.WrappedException;

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

-import org.eclipse.mylyn.docs.intent.client.ui.ide.builder.IntentNature;

-import org.eclipse.mylyn.docs.intent.client.ui.ide.builder.ToggleNatureAction;

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

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

-import org.eclipse.mylyn.docs.intent.collab.common.location.IntentLocations;

-import org.eclipse.mylyn.docs.intent.collab.repository.RepositoryConnectionException;

-import org.eclipse.mylyn.docs.intent.core.compiler.TraceabilityIndex;

-import org.eclipse.mylyn.docs.intent.core.compiler.TraceabilityIndexEntry;

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

 

 /**

  * Tests the Intent demo, part 1: navigation behavior.

  * 

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

  */

-public abstract class AbstractDemoTest extends AbstractIntentUITest {

+public abstract class AbstractDemoTest extends AbstractZipBasedTest {

 

 	protected static final String TEST_COMPILER_NO_ERROR_MSG = "The compiler failed to detect errors";

 

@@ -47,91 +33,13 @@
 

 	private static final String DEMO_ZIP_LOCATION = "data/unit/demo/demo.zip";

 

-	private static final String BUNDLE_NAME = "org.eclipse.mylyn.docs.intent.client.ui.test";

-

 	private static final String INTENT_PROJECT_NAME = "org.eclipse.emf.compare.idoc";

 

-	private static final int TIME_TO_WAIT = 300;

-

-	private static final int RECENT_COMPILATION_DELAY = 60000;

-

-	private static final long TIME_OUT_DELAY = 10000;

-

 	/**

-	 * {@inheritDoc}

-	 * 

-	 * @see org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractIntentUITest#setUp()

+	 * Constructor.

 	 */

-	@Override

-	protected void setUp() throws Exception {

-		super.setUp();

-

-		// Step 1 : import the demo projects

-		WorkspaceUtils.unzipAllProjects(BUNDLE_NAME, DEMO_ZIP_LOCATION, new NullProgressMonitor());

-

-		intentProject = ResourcesPlugin.getWorkspace().getRoot().getProject(INTENT_PROJECT_NAME);

-

-		// workaround hudson issue

-		if (waitForNature()) {

-			ToggleNatureAction.toggleNature(intentProject);

-			waitForAllOperationsInUIThread();

-			assertFalse(waitForNature());

-		}

-

-		// Step 2 : setting the intent repository

-		// and wait its complete initialization

-		setUpRepository(intentProject);

-		boolean repositoryInitialized = false;

-		long startTime = System.currentTimeMillis();

-		boolean timeOutDetected = false;

-		while (!repositoryInitialized && !timeOutDetected) {

-			try {

-				Resource resource = repositoryAdapter

-						.getResource(IntentLocations.TRACEABILITY_INFOS_INDEX_PATH);

-				// We ensure that the compiler did its work less that one minute ago

-				repositoryInitialized = resource != null

-						&& !resource.getContents().isEmpty()

-						&& isRecentTraceabilityIndex((TraceabilityIndex)resource.getContents().iterator()

-								.next());

-				timeOutDetected = System.currentTimeMillis() - startTime > TIME_OUT_DELAY;

-				Thread.sleep(TIME_TO_WAIT);

-			} catch (WrappedException e) {

-				// Try again

-			}

-		}

-

-		assertFalse("The Intent clients have not been launched although the project has been imported",

-				timeOutDetected);

-		registerRepositoryListener();

-		repositoryListener.clearPreviousEntries();

-		waitForSynchronizer();

-	}

-

-	private boolean waitForNature() throws RepositoryConnectionException, CoreException, InterruptedException {

-		boolean timeOutDetected = false;

-		long startTime = System.currentTimeMillis();

-		// while the project does not have the correct nature or is unaccessible, the repository is null

-		while (!intentProject.hasNature(IntentNature.NATURE_ID) && !timeOutDetected) {

-			timeOutDetected = System.currentTimeMillis() - startTime > TIME_OUT_DELAY;

-			Thread.sleep(TIME_TO_WAIT);

-		}

-		return timeOutDetected;

-	}

-

-	/**

-	 * Indicates if the given traceability index is recent or is old.

-	 * 

-	 * @param traceabilityIndex

-	 *            the traceability index to test

-	 * @return true if the given traceability index has been compiled less than a minute ago, false otherwise

-	 */

-	private boolean isRecentTraceabilityIndex(TraceabilityIndex traceabilityIndex) {

-		if (traceabilityIndex.getEntries().size() > 0) {

-			final TraceabilityIndexEntry entry = traceabilityIndex.getEntries().iterator().next();

-			BigInteger compilationTime = entry.getCompilationTime();

-			return compilationTime.doubleValue() > (System.currentTimeMillis() - RECENT_COMPILATION_DELAY);

-		}

-		return false;

+	public AbstractDemoTest() {

+		super(DEMO_ZIP_LOCATION, INTENT_PROJECT_NAME);

 	}

 

 }

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/demo/synchronization/EcoreTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/demo/synchronization/EcoreTest.java
index 81a8f18..c484280 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/demo/synchronization/EcoreTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/demo/synchronization/EcoreTest.java
@@ -149,7 +149,7 @@
 

 		// Step 4 : apply quick fix

 		repositoryListener.clearPreviousEntries();

-		AnnotationUtils.applyAnnotationFix(repositoryAdapter, annotation);

+		AnnotationUtils.mergeToWorkingCopy(repositoryAdapter, annotation);

 		waitForSynchronizer();

 

 		// Step 5 : ensure that synchronization issues no longer exists

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
new file mode 100644
index 0000000..2f3ce78
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/update/QuickFixTest.java
@@ -0,0 +1,92 @@
+/*******************************************************************************

+ * Copyright (c) 2011 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 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;

+

+/**

+ * Tests the quick fixes updates.

+ * 

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

+ */

+public class QuickFixTest extends AbstractZipBasedTest {

+	private IntentEditor editor;

+

+	private IntentEditorDocument document;

+

+	/**

+	 * Constructor.

+	 */

+	public QuickFixTest() {

+		super("data/unit/documents/quickfixes/intentProject.zip", "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());

+	}

+

+	/**

+	 * Test that the model element changes are fixed.

+	 * 

+	 * @throws IOException

+	 *             if comparison fails

+	 */

+	public void testQuickFixes() throws IOException {

+		AnnotationUtils.displayAnnotations(editor);

+		fixIssue("The EClass A is defined in the <b>Working Copy</b> model<br/>but not in the <b>Current Document</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.");

+		assertTrue(AnnotationUtils.getIntentAnnotations(editor, IntentAnnotationMessageType.SYNC_WARNING)

+				.isEmpty());

+		String finalUpdatedDocText = FileToStringConverter.getFileAsString(new File(

+				"data/unit/documents/quickfixes/final.intent"));

+		assertEquals(finalUpdatedDocText, document.get());

+	}

+

+	/**

+	 * Fix the issue associated to the given message.

+	 * 

+	 * @param message

+	 *            the annotation message

+	 */

+	private void fixIssue(String message) {

+		for (IntentAnnotation annotation : AnnotationUtils.getIntentAnnotations(editor,

+				IntentAnnotationMessageType.SYNC_WARNING)) {

+			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;

+			}

+		}

+		fail("Annotation not found: " + message);

+	}

+

+}

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AbstractZipBasedTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AbstractZipBasedTest.java
new file mode 100644
index 0000000..b3b1c02
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AbstractZipBasedTest.java
@@ -0,0 +1,136 @@
+/*******************************************************************************

+ * Copyright (c) 2011 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.util;

+

+import java.math.BigInteger;

+

+import org.eclipse.core.resources.ResourcesPlugin;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.emf.common.util.WrappedException;

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

+import org.eclipse.mylyn.docs.intent.client.ui.ide.builder.IntentNature;

+import org.eclipse.mylyn.docs.intent.client.ui.ide.builder.ToggleNatureAction;

+import org.eclipse.mylyn.docs.intent.collab.common.location.IntentLocations;

+import org.eclipse.mylyn.docs.intent.collab.repository.RepositoryConnectionException;

+import org.eclipse.mylyn.docs.intent.core.compiler.TraceabilityIndex;

+import org.eclipse.mylyn.docs.intent.core.compiler.TraceabilityIndexEntry;

+

+/**

+ * Tests the Intent demo, part 1: navigation behavior.

+ * 

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

+ */

+public abstract class AbstractZipBasedTest extends AbstractIntentUITest {

+

+	private String location;

+

+	private String projectName;

+

+	private static final String BUNDLE_NAME = "org.eclipse.mylyn.docs.intent.client.ui.test";

+

+	private static final int TIME_TO_WAIT = 300;

+

+	private static final int RECENT_COMPILATION_DELAY = 60000;

+

+	private static final long TIME_OUT_DELAY = 10000;

+

+	/**

+	 * Constructor.

+	 * 

+	 * @param zipLocation

+	 *            the files to expand

+	 * @param intentProjectName

+	 *            the project name

+	 */

+	public AbstractZipBasedTest(String zipLocation, String intentProjectName) {

+		this.location = zipLocation;

+		this.projectName = intentProjectName;

+	}

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractIntentUITest#setUp()

+	 */

+	@Override

+	protected void setUp() throws Exception {

+		super.setUp();

+

+		// Step 1 : import the demo projects

+		WorkspaceUtils.unzipAllProjects(BUNDLE_NAME, location, new NullProgressMonitor());

+

+		intentProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

+

+		// workaround hudson issue

+		if (waitForNature()) {

+			ToggleNatureAction.toggleNature(intentProject);

+			waitForAllOperationsInUIThread();

+			assertFalse(waitForNature());

+		}

+

+		// Step 2 : setting the intent repository

+		// and wait its complete initialization

+		setUpRepository(intentProject);

+		boolean repositoryInitialized = false;

+		long startTime = System.currentTimeMillis();

+		boolean timeOutDetected = false;

+		while (!repositoryInitialized && !timeOutDetected) {

+			try {

+				Resource resource = repositoryAdapter

+						.getResource(IntentLocations.TRACEABILITY_INFOS_INDEX_PATH);

+				// We ensure that the compiler did its work less that one minute ago

+				repositoryInitialized = resource != null

+						&& !resource.getContents().isEmpty()

+						&& isRecentTraceabilityIndex((TraceabilityIndex)resource.getContents().iterator()

+								.next());

+				timeOutDetected = System.currentTimeMillis() - startTime > TIME_OUT_DELAY;

+				Thread.sleep(TIME_TO_WAIT);

+			} catch (WrappedException e) {

+				// Try again

+			}

+		}

+

+		assertFalse("The Intent clients have not been launched although the project has been imported",

+				timeOutDetected);

+		registerRepositoryListener();

+		repositoryListener.clearPreviousEntries();

+		waitForSynchronizer();

+	}

+

+	private boolean waitForNature() throws RepositoryConnectionException, CoreException, InterruptedException {

+		boolean timeOutDetected = false;

+		long startTime = System.currentTimeMillis();

+		// while the project does not have the correct nature or is unaccessible, the repository is null

+		while (!intentProject.hasNature(IntentNature.NATURE_ID) && !timeOutDetected) {

+			timeOutDetected = System.currentTimeMillis() - startTime > TIME_OUT_DELAY;

+			Thread.sleep(TIME_TO_WAIT);

+		}

+		return timeOutDetected;

+	}

+

+	/**

+	 * Indicates if the given traceability index is recent or is old.

+	 * 

+	 * @param traceabilityIndex

+	 *            the traceability index to test

+	 * @return true if the given traceability index has been compiled less than a minute ago, false otherwise

+	 */

+	private boolean isRecentTraceabilityIndex(TraceabilityIndex traceabilityIndex) {

+		if (traceabilityIndex.getEntries().size() > 0) {

+			final TraceabilityIndexEntry entry = traceabilityIndex.getEntries().iterator().next();

+			BigInteger compilationTime = entry.getCompilationTime();

+			return compilationTime.doubleValue() > (System.currentTimeMillis() - RECENT_COMPILATION_DELAY);

+		}

+		return false;

+	}

+

+}

diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java
index 8cdfee0..face5b9 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java
@@ -22,15 +22,20 @@
 import org.eclipse.emf.compare.diff.service.DiffService;

 import org.eclipse.emf.compare.match.metamodel.MatchModel;

 import org.eclipse.emf.compare.match.service.MatchService;

+import org.eclipse.emf.ecore.EObject;

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

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

 import org.eclipse.jface.text.source.Annotation;

 import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentDocumentProvider;

 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.collab.handlers.adapters.RepositoryAdapter;

 import org.eclipse.mylyn.docs.intent.core.compiler.SynchronizerCompilationStatus;

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

+import org.eclipse.mylyn.docs.intent.modelingunit.update.SyncStatusUpdater;

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

 

 /**

  * Provide utilities to ease annotations manipulation.

@@ -102,6 +107,31 @@
 	}

 

 	/**

+	 * Returns all annotations of the given {@link IntentAnnotationMessageType}.

+	 * 

+	 * @param intentEditor

+	 *            the editor to search into

+	 * @param messageType

+	 *            the searched {@link IntentAnnotationMessageType}

+	 * @return the annotations

+	 */

+	public static List<IntentAnnotation> getIntentAnnotations(IntentEditor intentEditor,

+			IntentAnnotationMessageType messageType) {

+		List<IntentAnnotation> res = new ArrayList<IntentAnnotation>();

+		Iterator<?> annotationIterator = ((IntentDocumentProvider)intentEditor.getDocumentProvider())

+				.getAnnotationModel(null).getAnnotationIterator();

+		while (annotationIterator.hasNext()) {

+			Object annotation = annotationIterator.next();

+			if (annotation instanceof IntentAnnotation) {

+				if (messageType.equals(((IntentAnnotation)annotation).getMessageType())) {

+					res.add((IntentAnnotation)annotation);

+				}

+			}

+		}

+		return res;

+	}

+

+	/**

 	 * Applies the given annotation quick fix.

 	 * 

 	 * @param repositoryAdapter

@@ -113,7 +143,7 @@
 	 * @throws IOException

 	 *             if merging fails

 	 */

-	public static void applyAnnotationFix(RepositoryAdapter repositoryAdapter, IntentAnnotation syncAnnotation)

+	public static void mergeToWorkingCopy(RepositoryAdapter repositoryAdapter, IntentAnnotation syncAnnotation)

 			throws IOException, InterruptedException {

 		// Step 1 : getting the resources to compare URI

 		String workingCopyResourceURI = ((SynchronizerCompilationStatus)syncAnnotation.getCompilationStatus())

@@ -140,6 +170,43 @@
 	}

 

 	/**

+	 * Applies the annotation quick fix at the given index.

+	 * 

+	 * @param document

+	 *            the intent editor document

+	 * @param repositoryAdapter

+	 *            the repository adapter

+	 * @param syncAnnotation

+	 *            the sync annotation

+	 * @param index

+	 *            the annotation index

+	 */

+	public static void applyAnnotationFix(IntentEditorDocument document, RepositoryAdapter repositoryAdapter,

+			IntentAnnotation syncAnnotation, int index) {

+		// NOTE: similar to

+		// org.eclipse.mylyn.docs.intent.client.ui.editor.quickfix.UpdateModelingUnitFix.applyFix(RepositoryAdapter,

+		// IntentEditorDocument)

+

+		EObject modelingUnit = syncAnnotation.getCompilationStatus().getTarget();

+

+		while (modelingUnit != null && !(modelingUnit instanceof ModelingUnit)) {

+			modelingUnit = modelingUnit.eContainer();

+		}

+

+		if (modelingUnit != null) {

+			SyncStatusUpdater updater = new SyncStatusUpdater(repositoryAdapter);

+			updater.fixSynchronizationStatus((SynchronizerCompilationStatus)syncAnnotation

+					.getCompilationStatus());

+			document.reloadFromAST();

+		}

+

+		// FIXME WORKAROUND

+		// workaround issue when applying quick fixes : editor doesn't reflect modifications

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

+		// END WORKAROUND

+	}

+

+	/**

 	 * Displays the annotations for the given editor.

 	 * 

 	 * @param intentEditor