Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-10-16 15:28:12 +0000
committerChristian W. Damus2013-10-16 15:28:12 +0000
commit8563cccdf031cfac5912a8b84647addab4a67844 (patch)
tree6f7fc58b87df652e3ca4dd1e97c54d2bc4ba44a2
parent5e28ce8977b3dc20201e246dcf463ce149811355 (diff)
downloadorg.eclipse.uml2-8563cccdf031cfac5912a8b84647addab4a67844.tar.gz
org.eclipse.uml2-8563cccdf031cfac5912a8b84647addab4a67844.tar.xz
org.eclipse.uml2-8563cccdf031cfac5912a8b84647addab4a67844.zip
[409396] [Profile Definition] Invalid transformation from Profile to Ecore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=409396 Added an "Untyped Properties" option to UML-to-Ecore conversion. All four actions are supported: ignore, report, discard, process. Process defaults properties to EObject references. Default in the importer and convert-to UI is to report.
-rw-r--r--examples/org.eclipse.uml2.examples.uml.ui/src/org/eclipse/uml2/examples/uml/ui/dialogs/UML2EcoreConverterOptionsDialog.java9
-rw-r--r--plugins/org.eclipse.uml2.uml.ecore.importer/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/ui/UMLImporterDetailPage.java7
-rw-r--r--plugins/org.eclipse.uml2.uml/plugin.properties6
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java126
-rw-r--r--tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396.uml8
-rw-r--r--tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396Test.java181
-rw-r--r--tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java2
8 files changed, 336 insertions, 5 deletions
diff --git a/examples/org.eclipse.uml2.examples.uml.ui/src/org/eclipse/uml2/examples/uml/ui/dialogs/UML2EcoreConverterOptionsDialog.java b/examples/org.eclipse.uml2.examples.uml.ui/src/org/eclipse/uml2/examples/uml/ui/dialogs/UML2EcoreConverterOptionsDialog.java
index f251f8dd5..76edd7e5a 100644
--- a/examples/org.eclipse.uml2.examples.uml.ui/src/org/eclipse/uml2/examples/uml/ui/dialogs/UML2EcoreConverterOptionsDialog.java
+++ b/examples/org.eclipse.uml2.examples.uml.ui/src/org/eclipse/uml2/examples/uml/ui/dialogs/UML2EcoreConverterOptionsDialog.java
@@ -9,6 +9,7 @@
* IBM - initial API and implementation
* Kenn Hussey (Embarcadero Technologies) - 213218
* Kenn Hussey (CEA) - 322715
+ * Christian W. Damus (CEA) - 409396
*
*/
package org.eclipse.uml2.examples.uml.ui.dialogs;
@@ -170,6 +171,14 @@ public class UML2EcoreConverterOptionsDialog
UMLUtil.UML2EcoreConverter.OPTION__CAMEL_CASE_NAMES, new String[]{
ignoreChoiceLabel, reportChoiceLabel, processChoiceLabel},
processChoiceLabel);
+
+ createOptionArea(
+ parent,
+ UMLExamplesUIPlugin.INSTANCE
+ .getString("_UI_UntypedProperties_label"), //$NON-NLS-1$
+ UMLUtil.UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES,
+ new String[]{ignoreChoiceLabel, reportChoiceLabel,
+ discardChoiceLabel, processChoiceLabel}, reportChoiceLabel);
}
}
diff --git a/plugins/org.eclipse.uml2.uml.ecore.importer/META-INF/MANIFEST.MF b/plugins/org.eclipse.uml2.uml.ecore.importer/META-INF/MANIFEST.MF
index 48030894a..69871ec60 100644
--- a/plugins/org.eclipse.uml2.uml.ecore.importer/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.uml2.uml.ecore.importer/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.uml2.uml.ecore.importer;singleton:=true
-Bundle-Version: 2.7.0.qualifier
+Bundle-Version: 2.8.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.uml2.uml.ecore.importer.UMLImporterPlugin$Implementation
Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/ui/UMLImporterDetailPage.java b/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/ui/UMLImporterDetailPage.java
index 702b5fb92..cdcc99186 100644
--- a/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/ui/UMLImporterDetailPage.java
+++ b/plugins/org.eclipse.uml2.uml.ecore.importer/src/org/eclipse/uml2/uml/ecore/importer/ui/UMLImporterDetailPage.java
@@ -9,6 +9,7 @@
* IBM - initial API and implementation
* Kenn Hussey (Embarcadero Technologies) - 213218
* Kenn Hussey (CEA) - 322715
+ * Christian W. Damus (CEA) - 409396
*
*/
package org.eclipse.uml2.uml.ecore.importer.ui;
@@ -255,6 +256,12 @@ public class UMLImporterDetailPage
UMLUtil.UML2EcoreConverter.OPTION__CAMEL_CASE_NAMES, new String[]{
ignoreChoiceLabel, reportChoiceLabel, processChoiceLabel},
ignoreChoiceLabel);
+ addOptionControl(
+ optionsComposite,
+ UMLImporterPlugin.INSTANCE.getString("_UI_UntypedProperties_label"), //$NON-NLS-1$
+ UMLUtil.UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES,
+ new String[]{ignoreChoiceLabel, reportChoiceLabel,
+ discardChoiceLabel, processChoiceLabel}, reportChoiceLabel);
scrolledComposite.setContent(optionsComposite);
scrolledComposite.setExpandHorizontal(true);
diff --git a/plugins/org.eclipse.uml2.uml/plugin.properties b/plugins/org.eclipse.uml2.uml/plugin.properties
index 5038bbc07..73d41ed37 100644
--- a/plugins/org.eclipse.uml2.uml/plugin.properties
+++ b/plugins/org.eclipse.uml2.uml/plugin.properties
@@ -8,7 +8,7 @@
# IBM - initial API and implementation
# Kenn Hussey (Embarcadero Technologies) - 156879, 215488, 213218, 204200
# Kenn Hussey (CEA) - 327039, 351774, 373709, 388636, 295864, 397140, 316165, 322715, 80307
-# Christian W. Damus (CEA) - 373643, 374012, 163556
+# Christian W. Damus (CEA) - 373643, 374012, 163556, 409396
#
# NLS_MESSAGEFORMAT_VAR
@@ -55,11 +55,13 @@ _UI_UML2EcoreConverter_ProcessDuplicateFeature_diagnostic = Processed feature ''
_UI_UML2EcoreConverter_ProcessDuplicateFeatureInheritance_diagnostic = Processed inheritance of feature ''{2}'' by class ''{0}'' as a duplicate of feature ''{1}''.
_UI_UML2EcoreConverter_ProcessSuperClassOrder_diagnostic = Re-ordered the super classes of class ''{0}'' for optimal code generation.
_UI_UML2EcoreConverter_ProcessAnnotationDetails_diagnostic = Annotated model element ''{0}'' with details from source ''{1}''.
+_UI_UML2EcoreConverter_ProcessUntypedProperty_diagnostic = Feature ''{0}'' has no type specified and is assigned ''{1}'' by default.
_UI_UML2EcoreConverter_DiscardDuplicateOperation_diagnostic = Discarded operation ''{0}'' because it is a duplicate of inherited operation ''{1}''.
_UI_UML2EcoreConverter_DiscardDuplicateOperationInheritance_diagnostic = Discarded inheritance of operation ''{2}'' by class ''{0}'' because it is a duplicate of operation ''{1}''.
_UI_UML2EcoreConverter_DiscardDuplicateFeature_diagnostic = Discarded feature ''{0}'' because it is a duplicate of inherited feature ''{1}''.
_UI_UML2EcoreConverter_DiscardDuplicateFeatureInheritance_diagnostic = Discarded inheritance of feature ''{2}'' by class ''{0}'' because it is a duplicate of feature ''{1}''.
+_UI_UML2EcoreConverter_DiscardUntypedProperty_diagnostic = Feature ''{0}'' has no type and has been discarded.
_UI_UML2EcoreConverter_ReportEcoreTaggedValue_diagnostic = Model element ''{0}'' should be processed based on Ecore tag ''{1}'' with value of ''{2}''.
_UI_UML2EcoreConverter_ReportRedefiningOperation_diagnostic = Operation ''{0}'' should be annotated as redefinition of operation ''{1}''.
@@ -73,6 +75,7 @@ _UI_UML2EcoreConverter_ReportDuplicateFeature_diagnostic = Feature ''{0}'' is a
_UI_UML2EcoreConverter_ReportDuplicateFeatureInheritance_diagnostic = Class ''{0}'' inherits duplicate features ''{1}'' and ''{2}''.
_UI_UML2EcoreConverter_ReportSuperClassOrder_diagnostic = The super classes of class ''{0}'' should be re-ordered for optimal code generation.
_UI_UML2EcoreConverter_ReportAnnotationDetails_diagnostic = Model element ''{0}'' should be annotated with details from source ''{1}''.
+_UI_UML2EcoreConverter_ReportUntypedProperty_diagnostic = Feature ''{0}'' has no type specified.
_UI_Ecore2UMLConverter_ProcessEcoreTaggedValue_diagnostic = Applied Ecore tag ''{1}'' with value of ''{2}'' to element ''{0}''.
_UI_Ecore2UMLConverter_ProcessRedefinesAnnotation_diagnostic = Made ''{0}'' redefine ''{1}'' based on an annotation.
@@ -197,6 +200,7 @@ _UI_AnnotationDetails_label = Annotation Details
_UI_InvariantConstraints_label = Invariant Constraints
_UI_OperationBodies_label = Operation Bodies
_UI_Comments_label = Comments
+_UI_UntypedProperties_label = Untyped Properties
_UI_RedefinesAnnotations_label = Redefines Annotations
_UI_SubsetsAnnotations_label = Subsets Annotations
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
index 3b8fa86ff..ccb4d9da7 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
@@ -12,7 +12,7 @@
* Kenn Hussey - 286329, 313601, 314971, 344907, 236184, 335125
* Kenn Hussey (CEA) - 327039, 358792, 364419, 366350, 307343, 382637, 273949, 389542, 389495, 316165, 392833, 399544, 322715, 163556, 212765, 397324, 204658, 408612, 411731
* Yann Tanguy (CEA) - 350402
- * Christian W. Damus (CEA) - 392833, 251963
+ * Christian W. Damus (CEA) - 392833, 251963, 409396
*
*/
package org.eclipse.uml2.uml.util;
@@ -2295,6 +2295,15 @@ public class UMLUtil
*/
public static final String OPTION__VALIDATION_DELEGATES = "VALIDATION_DELEGATES"; //$NON-NLS-1$
+ /**
+ * The option for handling untyped properties. Supported choices are
+ * {@code OPTION__IGNORE}, {@code OPTION__REPORT},
+ * {@code OPTION__DISCARD}, and {@code OPTION__PROCESS}.
+ *
+ * @since 4.2
+ */
+ public static final String OPTION__UNTYPED_PROPERTIES = "UNTYPED_PROPERTIES"; //$NON-NLS-1$
+
private static final int DIAGNOSTIC_CODE_OFFSET = 2000;
/**
@@ -2388,6 +2397,13 @@ public class UMLUtil
*/
public static final int CAMEL_CASE_NAME = DIAGNOSTIC_CODE_OFFSET + 16;
+ /**
+ * The diagnostic code for untyped properties.
+ *
+ * @since 4.2
+ */
+ public static final int UNTYPED_PROPERTY = DIAGNOSTIC_CODE_OFFSET + 17;
+
protected static final Pattern ANNOTATION_PATTERN = Pattern
.compile("\\G\\s*((?>\\\\.|\\S)+)((?:\\s+(?>\\\\.|\\S)+\\s*+=\\s*(['\"])((?>\\\\.|.)*?)\\3)*)"); //$NON-NLS-1$
@@ -3273,7 +3289,17 @@ public class UMLUtil
EStructuralFeature eStructuralFeature = null;
Classifier type = (Classifier) property.getType();
- if (isEClass(type)) {
+ if ((type == null)
+ && OPTION__PROCESS.equals(options
+ .get(OPTION__UNTYPED_PROPERTIES))) {
+
+ EReference eReference = (EReference) (eStructuralFeature = EcoreFactory.eINSTANCE
+ .createEReference());
+ elementToEModelElementMap.put(property, eReference);
+
+ eReference.setContainment(property.isComposite());
+ eReference.setEType(EcorePackage.Literals.EOBJECT);
+ } else if (isEClass(type)) {
EReference eReference = (EReference) (eStructuralFeature = EcoreFactory.eINSTANCE
.createEReference());
elementToEModelElementMap.put(property, eReference);
@@ -3331,7 +3357,10 @@ public class UMLUtil
}
}
- caseTypedElement(property);
+ if (type != null) {
+ caseTypedElement(property);
+ }
+
caseMultiplicityElement(property);
defaultCase(property);
@@ -5992,6 +6021,83 @@ public class UMLUtil
.get(0)));
}
+ /**
+ * Applies the conversion option to untyped properties in the source UML
+ * model.
+ *
+ * @param options
+ * the current conversion options
+ * @param diagnostics
+ * collector of problem reports
+ * @param context
+ * validation context for problem reporting
+ *
+ * @since 4.2
+ */
+ protected void processUntypedProperties(
+ final Map<String, String> options,
+ final DiagnosticChain diagnostics,
+ final Map<Object, Object> context) {
+
+ for (final Map.Entry<Element, EModelElement> entry : elementToEModelElementMap
+ .entrySet()) {
+
+ Element element = entry.getKey();
+
+ if ((element instanceof Property)
+ && (((Property) element).getType() == null)) {
+ final String option = options
+ .get(OPTION__UNTYPED_PROPERTIES);
+ EModelElement eModelElement = entry.getValue();
+
+ if (OPTION__PROCESS.equals(option) && (diagnostics != null)) {
+ diagnostics
+ .add(new BasicDiagnostic(
+ Diagnostic.INFO,
+ UMLValidator.DIAGNOSTIC_SOURCE,
+ UNTYPED_PROPERTY,
+ UMLPlugin.INSTANCE
+ .getString(
+ "_UI_UML2EcoreConverter_ProcessUntypedProperty_diagnostic", //$NON-NLS-1$
+ getMessageSubstitutions(context,
+ eModelElement,
+ ((EStructuralFeature) eModelElement)
+ .getEType())),
+ new Object[]{eModelElement}));
+ } else if (OPTION__REPORT.equals(option)
+ && (diagnostics != null)) {
+ diagnostics
+ .add(new BasicDiagnostic(
+ Diagnostic.ERROR,
+ UMLValidator.DIAGNOSTIC_SOURCE,
+ UNTYPED_PROPERTY,
+ UMLPlugin.INSTANCE
+ .getString(
+ "_UI_UML2EcoreConverter_ReportUntypedProperty_diagnostic", //$NON-NLS-1$
+ getMessageSubstitutions(context,
+ eModelElement)),
+ new Object[]{eModelElement}));
+ } else if (OPTION__DISCARD.equals(option)) {
+ if (diagnostics != null) {
+ diagnostics
+ .add(new BasicDiagnostic(
+ Diagnostic.WARNING,
+ UMLValidator.DIAGNOSTIC_SOURCE,
+ UNTYPED_PROPERTY,
+ UMLPlugin.INSTANCE
+ .getString(
+ "_UI_UML2EcoreConverter_DiscardUntypedProperty_diagnostic", //$NON-NLS-1$
+ getMessageSubstitutions(context,
+ eModelElement)),
+ new Object[]{eModelElement}));
+ }
+
+ EcoreUtil.delete(eModelElement, true);
+ }
+ }
+ }
+ }
+
protected void processOptions(Map<String, String> options,
DiagnosticChain diagnostics, Map<Object, Object> context) {
@@ -6062,6 +6168,10 @@ public class UMLUtil
if (!OPTION__IGNORE.equals(options.get(OPTION__OPERATION_BODIES))) {
processOperationBodies(options, diagnostics, context);
}
+
+ if (!OPTION__IGNORE.equals(options.get(OPTION__UNTYPED_PROPERTIES))) {
+ processUntypedProperties(options, diagnostics, context);
+ }
}
public Collection<? extends EObject> convert(
@@ -10253,6 +10363,11 @@ public class UMLUtil
options.put(UML2EcoreConverter.OPTION__COMMENTS, OPTION__IGNORE);
}
+ if (!options.containsKey(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES)) {
+ options.put(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES,
+ OPTION__IGNORE);
+ }
+
return convertToEcore(package_, options, null, null);
}
@@ -10372,6 +10487,11 @@ public class UMLUtil
options.put(UML2EcoreConverter.OPTION__COMMENTS, OPTION__REPORT);
}
+ if (!options.containsKey(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES)) {
+ options.put(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES,
+ OPTION__REPORT);
+ }
+
@SuppressWarnings("unchecked")
Collection<EPackage> ePackages = (Collection<EPackage>) new UML2EcoreConverter()
.convert(Collections.singletonList(package_), options, diagnostics,
diff --git a/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396.uml b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396.uml
new file mode 100644
index 000000000..a8bed5250
--- /dev/null
+++ b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396.uml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_1Hu4oDZtEeOM1OjLQfqdjA" name="foo" URI="http://www.eclipse.org/uml2/foo" viewpoint="">
+ <packagedElement xmi:type="uml:Class" xmi:id="_6nK80DZtEeOM1OjLQfqdjA" name="MyClass">
+ <ownedAttribute xmi:id="_-bY1UDZtEeOM1OjLQfqdjA" name="untyped">
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_As8BMDZuEeOM1OjLQfqdjA"/>
+ </ownedAttribute>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396Test.java b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396Test.java
new file mode 100644
index 000000000..3ecca24fb
--- /dev/null
+++ b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/Bug409396Test.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2013 CEA and others.
+ * 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:
+ * Christian W. Damus (CEA) - initial API and implementation
+ */
+package org.eclipse.uml2.uml.bug.tests;
+
+import java.net.URL;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.DiagnosticChain;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.tests.util.StandaloneSupport;
+import org.eclipse.uml2.uml.util.UMLUtil;
+import org.eclipse.uml2.uml.util.UMLUtil.UML2EcoreConverter;
+import org.eclipse.uml2.uml.util.UMLValidator;
+
+/**
+ * Test suite for the changes introduced for Bug 409396.
+ *
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=409396
+ */
+public class Bug409396Test
+ extends TestCase {
+
+ private ResourceSet rset;
+
+ private Package model;
+
+ /**
+ * Initializes me with my name.
+ *
+ * @param name
+ * my name
+ */
+ public Bug409396Test(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(Bug409396Test.class, "Bug 409396 tests"); //$NON-NLS-1$
+ }
+
+ public void testConvertWithDefaultType() {
+ BasicDiagnostic diagnostics = new BasicDiagnostic();
+ EPackage ePackage = convertModel(UMLUtil.OPTION__PROCESS, diagnostics);
+ EStructuralFeature feature = getUntypedFeature(ePackage);
+ assertTrue("Feature not a reference", feature instanceof EReference);
+ assertSame(EcorePackage.Literals.EOBJECT, feature.getEType());
+ assertProblem(Diagnostic.INFO, diagnostics);
+ }
+
+ public void testConvertWithReporting() {
+ BasicDiagnostic diagnostics = new BasicDiagnostic();
+ EPackage ePackage = convertModel(UMLUtil.OPTION__REPORT, diagnostics);
+ EStructuralFeature feature = getUntypedFeature(ePackage);
+ assertNotNull("Feature not converted", feature);
+ assertNull("Feature has a type", feature.getEType());
+ assertProblem(Diagnostic.ERROR, diagnostics);
+ }
+
+ public void testConvertWithDiscard() {
+ BasicDiagnostic diagnostics = new BasicDiagnostic();
+ EPackage ePackage = convertModel(UMLUtil.OPTION__DISCARD, diagnostics);
+ EStructuralFeature feature = getUntypedFeature(ePackage);
+ assertNull("Feature was converted", feature);
+ assertProblem(Diagnostic.WARNING, diagnostics);
+ }
+
+ public void testConvertWithIgnore() {
+ BasicDiagnostic diagnostics = new BasicDiagnostic();
+ EPackage ePackage = convertModel(UMLUtil.OPTION__IGNORE, diagnostics);
+ EStructuralFeature feature = getUntypedFeature(ePackage);
+ assertNotNull("Feature not converted", feature);
+ assertNull("Feature has a type", feature.getEType());
+ assertNoProblem(diagnostics);
+ }
+
+ //
+ // Test framework
+ //
+
+ @Override
+ protected void setUp()
+ throws Exception {
+
+ rset = new ResourceSetImpl();
+
+ if (StandaloneSupport.isStandalone()) {
+ StandaloneSupport.init(rset);
+ }
+
+ model = getTestModel();
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception {
+
+ model = null;
+
+ for (Resource next : rset.getResources()) {
+ next.unload();
+ }
+
+ rset.getResources().clear();
+ rset.eAdapters().clear();
+ rset = null;
+ }
+
+ Package getTestModel() {
+ URL url = getClass().getResource("Bug409396.uml"); //$NON-NLS-1$
+ return (Package) UML2Util.load(rset,
+ URI.createURI(url.toExternalForm()), UMLPackage.Literals.PACKAGE);
+ }
+
+ EPackage convertModel(String action, DiagnosticChain diagnostics) {
+ Map<String, String> options = new java.util.HashMap<String, String>();
+ options.put(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES, action);
+ return UMLUtil.convertToEcore(model, options, diagnostics, null)
+ .iterator().next();
+ }
+
+ EStructuralFeature getUntypedFeature(EPackage ePackage) {
+ return ((EClass) ePackage.getEClassifier("MyClass"))
+ .getEStructuralFeature("untyped");
+ }
+
+ void assertProblem(int severity, Diagnostic diagnostic) {
+ Diagnostic found = null;
+
+ for (Diagnostic next : diagnostic.getChildren()) {
+ if (UMLValidator.DIAGNOSTIC_SOURCE.equals(next.getSource())
+ && (next.getCode() == UML2EcoreConverter.UNTYPED_PROPERTY)) {
+
+ found = next;
+ break;
+ }
+ }
+
+ assertNotNull("Did not find diagnostic", found);
+ assertEquals(severity, found.getSeverity());
+ }
+
+ void assertNoProblem(Diagnostic diagnostic) {
+ Diagnostic found = null;
+
+ for (Diagnostic next : diagnostic.getChildren()) {
+ if (UMLValidator.DIAGNOSTIC_SOURCE.equals(next.getSource())
+ && (next.getCode() == UML2EcoreConverter.UNTYPED_PROPERTY)) {
+
+ found = next;
+ break;
+ }
+ }
+
+ assertNull("Found the diagnostic", found);
+ }
+}
diff --git a/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java
index a43d733a8..e66cd9b80 100644
--- a/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java
+++ b/tests/org.eclipse.uml2.uml.tests/src/org/eclipse/uml2/uml/bug/tests/UMLBugTests.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Christian W. Damus (CEA) - initial API and implementation
+ * Christian W. Damus (CEA) - 409396
*/
package org.eclipse.uml2.uml.bug.tests;
@@ -37,6 +38,7 @@ public class UMLBugTests
result.addTest(Bug392833Test.suite());
result.addTest(Bug403365Test.suite());
result.addTest(Bug300957Test.suite());
+ result.addTest(Bug409396Test.suite());
return result;
}

Back to the top