Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-04-21 16:56:32 +0000
committerCamille Letavernier2015-04-22 12:52:17 +0000
commitb90a0c78dfb69ec4004c18b6615eff3669631f15 (patch)
tree0b0a4af0f3d7ca09bb9ff2e925ef29820f93db2e /tests/junit/plugins/junit
parente27052d82685485ec3727023877ee37993b9ba63 (diff)
downloadorg.eclipse.papyrus-b90a0c78dfb69ec4004c18b6615eff3669631f15.tar.gz
org.eclipse.papyrus-b90a0c78dfb69ec4004c18b6615eff3669631f15.tar.xz
org.eclipse.papyrus-b90a0c78dfb69ec4004c18b6615eff3669631f15.zip
Bug 458685: [Commands] Stereotyped element deletion = dangling stereotypes left in the model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=458685 Fix cases of stereotype applications being missed in deletion of dependents of a UML element. Includes JUnit regression test. Change-Id: I1e2a2705564e0708892a30716492eec1f25d40f0 Reviewed-on: https://git.eclipse.org/r/46196 Tested-by: Hudson CI Reviewed-by: Camille Letavernier <camille.letavernier@cea.fr>
Diffstat (limited to 'tests/junit/plugins/junit')
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java
index dceec239ec7..d09562b2c38 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/AbstractModelFixture.java
@@ -10,10 +10,13 @@
* Christian W. Damus (CEA) - Initial API and implementation
* Christian W. Damus - bug 399859
* Christian W. Damus - bug 451230
+ * Christian W. Damus - bug 458685
*
*/
package org.eclipse.papyrus.junit.utils.rules;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
@@ -33,8 +36,14 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
@@ -45,6 +54,7 @@ import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.IWorkspaceCommandStack;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
@@ -128,6 +138,48 @@ public abstract class AbstractModelFixture<T extends EditingDomain> extends Test
return domain;
}
+ public void execute(Command command) {
+ assertThat("Command not executable", command.canExecute(), is(true));
+ getEditingDomain().getCommandStack().execute(command);
+ }
+
+ public IStatus execute(IUndoableOperation operation, IProgressMonitor monitor, IAdaptable info) {
+ assertThat("Operation not executable", operation.canExecute(), is(true));
+ assertThat("No operation history available", getEditingDomain().getCommandStack(), instanceOf(IWorkspaceCommandStack.class));
+
+ try {
+ IWorkspaceCommandStack stack = (IWorkspaceCommandStack) getEditingDomain().getCommandStack();
+ operation.addContext(stack.getDefaultUndoContext());
+ return stack.getOperationHistory().execute(operation, monitor, info);
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ fail("Command execution failed: " + e.getLocalizedMessage());
+ return null; // Unreachable
+ }
+ }
+
+ public IStatus execute(IUndoableOperation operation) {
+ return execute(operation, null, null);
+ }
+
+ public boolean canUndo() {
+ return getEditingDomain().getCommandStack().canUndo();
+ }
+
+ public void undo() {
+ assertThat("Cannot undo", canUndo(), is(true));
+ getEditingDomain().getCommandStack().undo();
+ }
+
+ public boolean canRedo() {
+ return getEditingDomain().getCommandStack().canRedo();
+ }
+
+ public void redo() {
+ assertThat("Cannot redo", canRedo(), is(true));
+ getEditingDomain().getCommandStack().redo();
+ }
+
public ResourceSet getResourceSet() {
EditingDomain domain = getEditingDomain();
return (domain == null) ? null : domain.getResourceSet();

Back to the top