Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-01-21 17:13:29 +0000
committerChristian W. Damus2015-01-21 20:50:49 +0000
commit83de1b8003bf87fcfa260982f15975a117fc71b5 (patch)
tree11cd54d74f3ed70e054854f0e466be6f7c28ce6a /tests/junit/plugins/uml/decoratormodel
parentc42dda4199efe4f677ce20e510a3eb80f38605a2 (diff)
downloadorg.eclipse.papyrus-83de1b8003bf87fcfa260982f15975a117fc71b5.tar.gz
org.eclipse.papyrus-83de1b8003bf87fcfa260982f15975a117fc71b5.tar.xz
org.eclipse.papyrus-83de1b8003bf87fcfa260982f15975a117fc71b5.zip
436666: "Stereotype repair" pop-up for already upgraded model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=436666 Detect orphaned (dangling) stereotype instances and suggest to delete them. Orphans are treated as a separate group from properly attached stereotype instances of the same schema (broken or not) because they cannot be repaired by profile application; they are not stereotype applications because they have no base elements. Also update some test models that are opened in editors to remove orphaned stereotype instances (which cause tests to hang on the repair dialog). Conflicts: extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/RepairStereotypes.java plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
Diffstat (limited to 'tests/junit/plugins/uml/decoratormodel')
-rw-r--r--tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/StereotypeApplicationRepairTest.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/StereotypeApplicationRepairTest.java b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/StereotypeApplicationRepairTest.java
index 209265b22ee..1b25b93e04a 100644
--- a/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/StereotypeApplicationRepairTest.java
+++ b/tests/junit/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.tests/src/org/eclipse/papyrus/uml/decoratormodel/tests/StereotypeApplicationRepairTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 CEA, Christian W. Damus, and others.
+ * Copyright (c) 2014, 2015 CEA, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,7 @@
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
* Christian W. Damus - bug 399859
+ * Christian W. Damus - bug 436666
*
*/
package org.eclipse.papyrus.uml.decoratormodel.tests;
@@ -22,12 +23,14 @@ import static org.junit.Assert.fail;
import java.util.Collection;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.core.utils.TransactionHelper;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
@@ -69,9 +72,10 @@ public class StereotypeApplicationRepairTest extends AbstractProfileExternalizat
public void wrongProfileVersion() {
assertThat("Should have found zombie stereotypes", zombies, notNullValue());
- EPackage schema = getOnlyZombieSchema();
- assertThat("Did not match schema to loaded profile", EcoreUtil.getRootContainer(schema), is((EObject) getTestProfile()));
- assertThat("EPackage is an unknown schema", getExtendedMetadata().demandedPackages(), not(hasItem(schema)));
+ IAdaptable schema = getOnlyZombieSchema();
+ EPackage ePackage = AdapterUtils.adapt(schema, EPackage.class).get();
+ assertThat("Did not match schema to loaded profile", EcoreUtil.getRootContainer(ePackage), is((EObject) getTestProfile()));
+ assertThat("EPackage is an unknown schema", getExtendedMetadata().demandedPackages(), not(hasItem(ePackage)));
IRepairAction action = zombies.getSuggestedRepairAction(schema);
assertThat("Wrong suggested repair action", action.kind(), is(IRepairAction.Kind.APPLY_LATEST_PROFILE_DEFINITION));
@@ -89,9 +93,10 @@ public class StereotypeApplicationRepairTest extends AbstractProfileExternalizat
public void missingProfileApplication() {
assertThat("Should have found zombie stereotypes", zombies, notNullValue());
- EPackage schema = getOnlyZombieSchema();
- assertThat("Did not match schema to loaded profile", EcoreUtil.getRootContainer(schema), is((EObject) getTestProfile()));
- assertThat("EPackage is an unknown schema", getExtendedMetadata().demandedPackages(), not(hasItem(schema)));
+ IAdaptable schema = getOnlyZombieSchema();
+ EPackage ePackage = AdapterUtils.adapt(schema, EPackage.class).get();
+ assertThat("Did not match schema to loaded profile", EcoreUtil.getRootContainer(ePackage), is((EObject) getTestProfile()));
+ assertThat("EPackage is an unknown schema", getExtendedMetadata().demandedPackages(), not(hasItem(ePackage)));
IRepairAction action = zombies.getSuggestedRepairAction(schema);
assertThat("Wrong suggested repair action", action.kind(), is(IRepairAction.Kind.APPLY_LATEST_PROFILE_DEFINITION));
@@ -109,8 +114,9 @@ public class StereotypeApplicationRepairTest extends AbstractProfileExternalizat
public void missingSchema() {
assertThat("Should have found zombie stereotypes", zombies, notNullValue());
- EPackage schema = getOnlyZombieSchema();
- assertThat("EPackage is not an unknown schema", getExtendedMetadata().demandedPackages(), hasItem(schema));
+ IAdaptable schema = getOnlyZombieSchema();
+ EPackage ePackage = AdapterUtils.adapt(schema, EPackage.class).get();
+ assertThat("EPackage is not an unknown schema", getExtendedMetadata().demandedPackages(), hasItem(ePackage));
IRepairAction action = zombies.getSuggestedRepairAction(schema);
assertThat("Wrong suggested repair action", action.kind(), is(IRepairAction.Kind.APPLY_LATEST_PROFILE_DEFINITION));
@@ -135,7 +141,7 @@ public class StereotypeApplicationRepairTest extends AbstractProfileExternalizat
houseKeeper.setField("zombies", snippet.getZombieStereotypes(decoratorModelResource));
}
- void repair(final EPackage schema, final IRepairAction action) {
+ void repair(final IAdaptable schema, final IRepairAction action) {
try {
TransactionHelper.run(modelSet.getEditingDomain(), new Runnable() {
@@ -150,8 +156,8 @@ public class StereotypeApplicationRepairTest extends AbstractProfileExternalizat
}
}
- EPackage getOnlyZombieSchema() {
- Collection<? extends EPackage> schemata = zombies.getZombiePackages();
+ IAdaptable getOnlyZombieSchema() {
+ Collection<? extends IAdaptable> schemata = zombies.getZombieSchemas();
assertThat("Wrong number of zombie packages", schemata.size(), is(1));
return schemata.iterator().next();
}

Back to the top