diff options
author | Cedric Dumoulin | 2015-01-19 20:42:50 +0000 |
---|---|---|
committer | Cedric Dumoulin | 2015-01-19 20:45:49 +0000 |
commit | e387772ca6f5d0e395d0d38696b4fa8612339790 (patch) | |
tree | 0564dde2defd93f8aa89643cc52c2cae93d360e2 /tests/junit/plugins/uml/profile | |
parent | ee7bafa2cb60621fb015ad887e7d52674a56af4f (diff) | |
download | org.eclipse.papyrus-e387772ca6f5d0e395d0d38696b4fa8612339790.tar.gz org.eclipse.papyrus-e387772ca6f5d0e395d0d38696b4fa8612339790.tar.xz org.eclipse.papyrus-e387772ca6f5d0e395d0d38696b4fa8612339790.zip |
[Profile] Drafter - Move tests plugin in the junits/tests hierarchy.
Diffstat (limited to 'tests/junit/plugins/uml/profile')
47 files changed, 4733 insertions, 0 deletions
diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.classpath b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.classpath new file mode 100644 index 00000000000..6314e9bd40c --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="test"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.project b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.project new file mode 100644 index 00000000000..ef9a1e83612 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.papyrus.uml.profile.drafter.tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..c537b63063c --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..fc264ab1269 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.uml.profile.drafter.tests +Bundle-Version: 1.1.0.qualifier +Fragment-Host: org.eclipse.papyrus.uml.profile.drafter;bundle-version="1.1.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.eclipse.papyrus.infra.gmfdiag.common +Export-Package: org.eclipse.papyrus.uml.profile.drafter.tests, + org.eclipse.papyrus.uml.profile.drafter.tests.exception +Bundle-Vendor: %providerName diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/about.html b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/about.html new file mode 100644 index 00000000000..d35d5aed64c --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 5, 2007</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + +</body> +</html> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/build.properties b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/build.properties new file mode 100644 index 00000000000..5cc1830cab8 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/build.properties @@ -0,0 +1,5 @@ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties +src.includes = about.html diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.di b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.notation b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.notation new file mode 100644 index 00000000000..42e09d02b2a --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.notation @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> +<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_BCCoINeIEeO9b7Ib8OAaeQ" type="PapyrusUMLProfileDiagram" name="NewDiagram" measurementUnit="Pixel"> + <children xmi:type="notation:Shape" xmi:id="_B3QY4NeIEeO9b7Ib8OAaeQ" type="1026"> + <children xmi:type="notation:DecorationNode" xmi:id="_B3QY4teIEeO9b7Ib8OAaeQ" type="1034"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_B3WfgNeIEeO9b7Ib8OAaeQ" type="1071"> + <styles xmi:type="notation:TitleStyle" xmi:id="_B3WfgdeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_B3WfgteIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_B3Wfg9eIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_B3WfhNeIEeO9b7Ib8OAaeQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_B3WfhdeIEeO9b7Ib8OAaeQ" type="1019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_B3WfhteIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_B3Wfh9eIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_B3WfiNeIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_B3WfideIEeO9b7Ib8OAaeQ"/> + </children> + <element xmi:type="uml:Stereotype" href="house.profile.uml#_B3KSQNeIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_B3QY4deIEeO9b7Ib8OAaeQ" x="133" y="233"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_DMK9YNeIEeO9b7Ib8OAaeQ" type="1026"> + <children xmi:type="notation:DecorationNode" xmi:id="_DMK9YteIEeO9b7Ib8OAaeQ" type="1034"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_DMK9Y9eIEeO9b7Ib8OAaeQ" type="1071"> + <styles xmi:type="notation:TitleStyle" xmi:id="_DMK9ZNeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_DMK9ZdeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_DMK9ZteIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DMK9Z9eIEeO9b7Ib8OAaeQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_DMK9aNeIEeO9b7Ib8OAaeQ" type="1019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_DMK9adeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_DMK9ateIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_DMK9a9eIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DMK9bNeIEeO9b7Ib8OAaeQ"/> + </children> + <element xmi:type="uml:Stereotype" href="house.profile.uml#_DME2wNeIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_DMK9YdeIEeO9b7Ib8OAaeQ" x="300" y="235"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_D_G2MNeIEeO9b7Ib8OAaeQ" type="1026"> + <children xmi:type="notation:DecorationNode" xmi:id="_D_G2MteIEeO9b7Ib8OAaeQ" type="1034"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_D_G2M9eIEeO9b7Ib8OAaeQ" type="1071"> + <styles xmi:type="notation:TitleStyle" xmi:id="_D_G2NNeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_D_G2NdeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_D_G2NteIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_D_G2N9eIEeO9b7Ib8OAaeQ"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_D_G2ONeIEeO9b7Ib8OAaeQ" type="1019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_D_G2OdeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_D_G2OteIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_D_G2O9eIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_D_G2PNeIEeO9b7Ib8OAaeQ"/> + </children> + <element xmi:type="uml:Stereotype" href="house.profile.uml#_D_AvkNeIEeO9b7Ib8OAaeQ"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_D_G2MdeIEeO9b7Ib8OAaeQ" x="465" y="237"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_KAJyodeIEeO9b7Ib8OAaeQ" type="1031"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_KAJypdeIEeO9b7Ib8OAaeQ" source="Stereotype_Annotation"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_KAJypteIEeO9b7Ib8OAaeQ" key="StereotypeWithQualifiedNameList" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_KAJyp9eIEeO9b7Ib8OAaeQ" key="StereotypeList" value="StandardProfile::Metaclass"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_KAJyqNeIEeO9b7Ib8OAaeQ" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_KAJyqdeIEeO9b7Ib8OAaeQ" key="PropStereoDisplay" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_KAJyqteIEeO9b7Ib8OAaeQ" key="StereotypePropertyLocation" value="Compartment"/> + </eAnnotations> + <children xmi:type="notation:DecorationNode" xmi:id="_KAJyo9eIEeO9b7Ib8OAaeQ" type="1084"/> + <element xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_KAJypNeIEeO9b7Ib8OAaeQ" x="300" y="64"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_Hwlm8NeMEeOxVfFeCUP2Mg" type="1031"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Hwlm9NeMEeOxVfFeCUP2Mg" source="Stereotype_Annotation"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Hwlm9deMEeOxVfFeCUP2Mg" key="StereotypeWithQualifiedNameList" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Hwlm9teMEeOxVfFeCUP2Mg" key="StereotypeList" value="StandardProfile::Metaclass"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Hwlm99eMEeOxVfFeCUP2Mg" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Hwlm-NeMEeOxVfFeCUP2Mg" key="PropStereoDisplay" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Hwlm-deMEeOxVfFeCUP2Mg" key="StereotypePropertyLocation" value="Compartment"/> + </eAnnotations> + <children xmi:type="notation:DecorationNode" xmi:id="_Hwlm8teMEeOxVfFeCUP2Mg" type="1084"/> + <element xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Package"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Hwlm89eMEeOxVfFeCUP2Mg" x="659" y="63"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_Iyl2gNeMEeOxVfFeCUP2Mg" type="1026"> + <children xmi:type="notation:DecorationNode" xmi:id="_Iyl2gteMEeOxVfFeCUP2Mg" type="1034"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_Iyl2g9eMEeOxVfFeCUP2Mg" type="1071"> + <styles xmi:type="notation:TitleStyle" xmi:id="_Iyl2hNeMEeOxVfFeCUP2Mg"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_Iyl2hdeMEeOxVfFeCUP2Mg"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_Iyl2hteMEeOxVfFeCUP2Mg"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Iyl2h9eMEeOxVfFeCUP2Mg"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_Iyr9INeMEeOxVfFeCUP2Mg" type="1019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_Iyr9IdeMEeOxVfFeCUP2Mg"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_Iyr9IteMEeOxVfFeCUP2Mg"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_Iyr9I9eMEeOxVfFeCUP2Mg"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Iyr9JNeMEeOxVfFeCUP2Mg"/> + </children> + <element xmi:type="uml:Stereotype" href="house.profile.uml#_IyZpQNeMEeOxVfFeCUP2Mg"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Iyl2gdeMEeOxVfFeCUP2Mg" x="685" y="257"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_BCCoIdeIEeO9b7Ib8OAaeQ"/> + <styles xmi:type="style:PapyrusViewStyle" xmi:id="_BCCoIteIEeO9b7Ib8OAaeQ"> + <owner xmi:type="uml:Profile" href="house.profile.uml#_BB8hgNeIEeO9b7Ib8OAaeQ"/> + </styles> + <element xmi:type="uml:Profile" href="house.profile.uml#_BB8hgNeIEeO9b7Ib8OAaeQ"/> + <edges xmi:type="notation:Connector" xmi:id="_Kk3pQNeIEeO9b7Ib8OAaeQ" type="1013" source="_B3QY4NeIEeO9b7Ib8OAaeQ" target="_KAJyodeIEeO9b7Ib8OAaeQ"> + <styles xmi:type="notation:FontStyle" xmi:id="_Kk3pQdeIEeO9b7Ib8OAaeQ"/> + <element xmi:type="uml:Extension" href="house.profile.uml#_KkxiodeIEeO9b7Ib8OAaeQ"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Kk3pQteIEeO9b7Ib8OAaeQ" points="[2, -3, -131, 132]$[109, -124, -24, 11]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_KlJ9INeIEeO9b7Ib8OAaeQ" id="(0.58,0.02830188679245283)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_KlJ9IdeIEeO9b7Ib8OAaeQ" id="(0.24,0.74)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_LADwc9eIEeO9b7Ib8OAaeQ" type="1013" source="_DMK9YNeIEeO9b7Ib8OAaeQ" target="_KAJyodeIEeO9b7Ib8OAaeQ"> + <styles xmi:type="notation:FontStyle" xmi:id="_LADwdNeIEeO9b7Ib8OAaeQ"/> + <element xmi:type="uml:Extension" href="house.profile.uml#_LADwcdeIEeO9b7Ib8OAaeQ"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_LADwddeIEeO9b7Ib8OAaeQ" points="[-1, -12, 11, 132]$[-28, -133, -16, 11]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_LAWEUNeIEeO9b7Ib8OAaeQ" id="(0.42,0.11320754716981132)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_LAWEUdeIEeO9b7Ib8OAaeQ" id="(0.3,0.78)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_LYYw4NeIEeO9b7Ib8OAaeQ" type="1013" source="_D_G2MNeIEeO9b7Ib8OAaeQ" target="_KAJyodeIEeO9b7Ib8OAaeQ"> + <styles xmi:type="notation:FontStyle" xmi:id="_LYYw4deIEeO9b7Ib8OAaeQ"/> + <element xmi:type="uml:Extension" href="house.profile.uml#_LYSqQdeIEeO9b7Ib8OAaeQ"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_LYYw4teIEeO9b7Ib8OAaeQ" points="[-16, -15, 139, 148]$[-157, -138, -2, 25]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_LYk-INeIEeO9b7Ib8OAaeQ" id="(0.4,0.14150943396226415)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_JNfp0NeMEeOxVfFeCUP2Mg" type="1013" source="_Iyl2gNeMEeOxVfFeCUP2Mg" target="_Hwlm8NeMEeOxVfFeCUP2Mg"> + <styles xmi:type="notation:FontStyle" xmi:id="_JNfp0deMEeOxVfFeCUP2Mg"/> + <element xmi:type="uml:Extension" href="house.profile.uml#_JNTckdeMEeOxVfFeCUP2Mg"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_JNfp0teMEeOxVfFeCUP2Mg" points="[-2, -9, 21, 153]$[-26, -153, -3, 9]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_JNfp09eMEeOxVfFeCUP2Mg" id="(0.43,0.08490566037735849)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_JNfp1NeMEeOxVfFeCUP2Mg" id="(0.46,0.82)"/> + </edges> +</notation:Diagram> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.uml b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.uml new file mode 100644 index 00000000000..741634c56eb --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/house.profile.uml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Profile xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_BB8hgNeIEeO9b7Ib8OAaeQ" name="house" metaclassReference="_KAJyoNeIEeO9b7Ib8OAaeQ _HwfgUNeMEeOxVfFeCUP2Mg"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_NVJ_kNeIEeO9b7Ib8OAaeQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <contents xmi:type="ecore:EPackage" xmi:id="_Kx8fIdeMEeOxVfFeCUP2Mg" name="house" nsURI="http:///schemas/house/_Kx8fINeMEeOxVfFeCUP2Mg/1" nsPrefix="house"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Kx8fNteMEeOxVfFeCUP2Mg" source="PapyrusVersion"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Kx8fN9eMEeOxVfFeCUP2Mg" key="Version" value="0.0.2"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Kx8fONeMEeOxVfFeCUP2Mg" key="Comment" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Kx8fOdeMEeOxVfFeCUP2Mg" key="Copyright" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Kx8fOteMEeOxVfFeCUP2Mg" key="Date" value="2014-05-09"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Kx8fO9eMEeOxVfFeCUP2Mg" key="Author" value=""/> + </eAnnotations> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_Kx8fIteMEeOxVfFeCUP2Mg" name="House"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Kx8fI9eMEeOxVfFeCUP2Mg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_B3KSQNeIEeO9b7Ib8OAaeQ"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_Kx8fJNeMEeOxVfFeCUP2Mg" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_Kx8fJteMEeOxVfFeCUP2Mg" name="Building"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Kx8fJ9eMEeOxVfFeCUP2Mg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_DME2wNeIEeO9b7Ib8OAaeQ"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_Kx8fKNeMEeOxVfFeCUP2Mg" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_Kx8fKteMEeOxVfFeCUP2Mg" name="Factory"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Kx8fK9eMEeOxVfFeCUP2Mg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_D_AvkNeIEeO9b7Ib8OAaeQ"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_Kx8fLNeMEeOxVfFeCUP2Mg" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_Kx8fLteMEeOxVfFeCUP2Mg" name="Box"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Kx8fL9eMEeOxVfFeCUP2Mg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_IyZpQNeMEeOxVfFeCUP2Mg"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_Kx8fMNeMEeOxVfFeCUP2Mg" name="base_Package" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/> + </eStructuralFeatures> + </eClassifiers> + </contents> + <contents xmi:type="ecore:EPackage" xmi:id="_NVJ_kdeIEeO9b7Ib8OAaeQ" name="house" nsURI="http:///schemas/house/_NVD48NeIEeO9b7Ib8OAaeQ/0" nsPrefix="house"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_NVJ_odeIEeO9b7Ib8OAaeQ" source="PapyrusVersion"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NVJ_oteIEeO9b7Ib8OAaeQ" key="Version" value="0.0.1"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NVJ_o9eIEeO9b7Ib8OAaeQ" key="Comment" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NVJ_pNeIEeO9b7Ib8OAaeQ" key="Copyright" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NVJ_pdeIEeO9b7Ib8OAaeQ" key="Date" value="2014-05-09"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NVJ_pteIEeO9b7Ib8OAaeQ" key="Author" value=""/> + </eAnnotations> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_NVJ_kteIEeO9b7Ib8OAaeQ" name="House"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_NVJ_k9eIEeO9b7Ib8OAaeQ" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_B3KSQNeIEeO9b7Ib8OAaeQ"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_NVJ_lNeIEeO9b7Ib8OAaeQ" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_NVJ_lteIEeO9b7Ib8OAaeQ" name="Building"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_NVJ_l9eIEeO9b7Ib8OAaeQ" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_DME2wNeIEeO9b7Ib8OAaeQ"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_NVJ_mNeIEeO9b7Ib8OAaeQ" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_NVJ_mteIEeO9b7Ib8OAaeQ" name="Factory"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_NVJ_m9eIEeO9b7Ib8OAaeQ" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_D_AvkNeIEeO9b7Ib8OAaeQ"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_NVJ_nNeIEeO9b7Ib8OAaeQ" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + </contents> + </eAnnotations> + <elementImport xmi:type="uml:ElementImport" xmi:id="_KAJyoNeIEeO9b7Ib8OAaeQ" alias="Class"> + <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </elementImport> + <elementImport xmi:type="uml:ElementImport" xmi:id="_HwfgUNeMEeOxVfFeCUP2Mg" alias="Package"> + <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Package"/> + </elementImport> + <packagedElement xmi:type="uml:Stereotype" xmi:id="_B3KSQNeIEeO9b7Ib8OAaeQ" name="House"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_KkxioNeIEeO9b7Ib8OAaeQ" name="base_Class" association="_KkxiodeIEeO9b7Ib8OAaeQ"> + <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </ownedAttribute> + </packagedElement> + <packagedElement xmi:type="uml:Stereotype" xmi:id="_DME2wNeIEeO9b7Ib8OAaeQ" name="Building"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_LADwcNeIEeO9b7Ib8OAaeQ" name="base_Class" association="_LADwcdeIEeO9b7Ib8OAaeQ"> + <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </ownedAttribute> + </packagedElement> + <packagedElement xmi:type="uml:Stereotype" xmi:id="_D_AvkNeIEeO9b7Ib8OAaeQ" name="Factory"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_LYSqQNeIEeO9b7Ib8OAaeQ" name="base_Class" association="_LYSqQdeIEeO9b7Ib8OAaeQ"> + <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </ownedAttribute> + </packagedElement> + <packagedElement xmi:type="uml:Extension" xmi:id="_KkxiodeIEeO9b7Ib8OAaeQ" name="E_House_Class1" memberEnd="_KkxioteIEeO9b7Ib8OAaeQ _KkxioNeIEeO9b7Ib8OAaeQ"> + <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_KkxioteIEeO9b7Ib8OAaeQ" name="extension_House" type="_B3KSQNeIEeO9b7Ib8OAaeQ" aggregation="composite" association="_KkxiodeIEeO9b7Ib8OAaeQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Extension" xmi:id="_LADwcdeIEeO9b7Ib8OAaeQ" name="E_Building_Class1" memberEnd="_LADwcteIEeO9b7Ib8OAaeQ _LADwcNeIEeO9b7Ib8OAaeQ"> + <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_LADwcteIEeO9b7Ib8OAaeQ" name="extension_Building" type="_DME2wNeIEeO9b7Ib8OAaeQ" aggregation="composite" association="_LADwcdeIEeO9b7Ib8OAaeQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Extension" xmi:id="_LYSqQdeIEeO9b7Ib8OAaeQ" name="E_Factory_Class1" memberEnd="_LYSqQteIEeO9b7Ib8OAaeQ _LYSqQNeIEeO9b7Ib8OAaeQ"> + <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_LYSqQteIEeO9b7Ib8OAaeQ" name="extension_Factory" type="_D_AvkNeIEeO9b7Ib8OAaeQ" aggregation="composite" association="_LYSqQdeIEeO9b7Ib8OAaeQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Stereotype" xmi:id="_IyZpQNeMEeOxVfFeCUP2Mg" name="Box"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_JNTckNeMEeOxVfFeCUP2Mg" name="base_Package" association="_JNTckdeMEeOxVfFeCUP2Mg"> + <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Package"/> + </ownedAttribute> + </packagedElement> + <packagedElement xmi:type="uml:Extension" xmi:id="_JNTckdeMEeOxVfFeCUP2Mg" name="E_Box_Package1" memberEnd="_JNTckteMEeOxVfFeCUP2Mg _JNTckNeMEeOxVfFeCUP2Mg"> + <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_JNTckteMEeOxVfFeCUP2Mg" name="extension_Box" type="_IyZpQNeMEeOxVfFeCUP2Mg" aggregation="composite" association="_JNTckdeMEeOxVfFeCUP2Mg"/> + </packagedElement> +</uml:Profile> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.di b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.notation b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.notation new file mode 100644 index 00000000000..c625edc0b32 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.notation @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <notation:Diagram xmi:id="_KRhN0AFpEeSZGsrO_8UE3g" type="PapyrusUMLProfileDiagram" name="NewDiagram" measurementUnit="Pixel"> + <children xmi:type="notation:Shape" xmi:id="_P0aOoAFpEeSZGsrO_8UE3g" type="1031"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_P0aOpAFpEeSZGsrO_8UE3g" source="Stereotype_Annotation"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P0aOpQFpEeSZGsrO_8UE3g" key="StereotypeWithQualifiedNameList" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P0aOpgFpEeSZGsrO_8UE3g" key="StereotypeList" value="StandardProfile::Metaclass"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P0aOpwFpEeSZGsrO_8UE3g" key="Stereotype_Presentation_Kind" value="HorizontalStereo"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P0aOqAFpEeSZGsrO_8UE3g" key="PropStereoDisplay" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_P0aOqQFpEeSZGsrO_8UE3g" key="StereotypePropertyLocation" value="Compartment"/> + </eAnnotations> + <children xmi:type="notation:DecorationNode" xmi:id="_P0aOogFpEeSZGsrO_8UE3g" type="1084"/> + <element xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_P0aOowFpEeSZGsrO_8UE3g" x="243" y="82"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_UPsuMAFpEeSZGsrO_8UE3g" type="1026"> + <children xmi:type="notation:DecorationNode" xmi:id="_UPsuMgFpEeSZGsrO_8UE3g" type="1034"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_UPsuMwFpEeSZGsrO_8UE3g" type="1071"> + <styles xmi:type="notation:TitleStyle" xmi:id="_UPsuNAFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_UPsuNQFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_UPsuNgFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_UPsuNwFpEeSZGsrO_8UE3g"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_UPsuOAFpEeSZGsrO_8UE3g" type="1019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_UPsuOQFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_UPsuOgFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_UPsuOwFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_UPsuPAFpEeSZGsrO_8UE3g"/> + </children> + <element xmi:type="uml:Stereotype" href="pets.profile.uml#_UPmnkAFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_UPsuMQFpEeSZGsrO_8UE3g" x="96" y="260"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_U4howQFpEeSZGsrO_8UE3g" type="1026"> + <children xmi:type="notation:DecorationNode" xmi:id="_U4howwFpEeSZGsrO_8UE3g" type="1034"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_U4nvYAFpEeSZGsrO_8UE3g" type="1071"> + <styles xmi:type="notation:TitleStyle" xmi:id="_U4nvYQFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_U4nvYgFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_U4nvYwFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_U4nvZAFpEeSZGsrO_8UE3g"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_U4nvZQFpEeSZGsrO_8UE3g" type="1019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_U4nvZgFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_U4nvZwFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_U4nvaAFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_U4nvaQFpEeSZGsrO_8UE3g"/> + </children> + <element xmi:type="uml:Stereotype" href="pets.profile.uml#_U4howAFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_U4howgFpEeSZGsrO_8UE3g" x="342" y="271"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_VppjsQFpEeSZGsrO_8UE3g" type="1026"> + <children xmi:type="notation:DecorationNode" xmi:id="_VppjswFpEeSZGsrO_8UE3g" type="1034"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_VppjtAFpEeSZGsrO_8UE3g" type="1071"> + <styles xmi:type="notation:TitleStyle" xmi:id="_VppjtQFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_VppjtgFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_VppjtwFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_VppjuAFpEeSZGsrO_8UE3g"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_VpvqUAFpEeSZGsrO_8UE3g" type="1019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_VpvqUQFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_VpvqUgFpEeSZGsrO_8UE3g"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_VpvqUwFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_VpvqVAFpEeSZGsrO_8UE3g"/> + </children> + <element xmi:type="uml:Stereotype" href="pets.profile.uml#_VppjsAFpEeSZGsrO_8UE3g"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_VppjsgFpEeSZGsrO_8UE3g" x="562" y="272"/> + </children> + <styles xmi:type="notation:StringValueStyle" xmi:id="_KRhN0QFpEeSZGsrO_8UE3g" name="diagram_compatibility_version" stringValue="1.0.0"/> + <styles xmi:type="notation:DiagramStyle" xmi:id="_KRhN0gFpEeSZGsrO_8UE3g"/> + <styles xmi:type="style:PapyrusViewStyle" xmi:id="_KRhN0wFpEeSZGsrO_8UE3g"> + <owner xmi:type="uml:Profile" href="pets.profile.uml#_KRbHMAFpEeSZGsrO_8UE3g"/> + </styles> + <element xmi:type="uml:Profile" href="pets.profile.uml#_KRbHMAFpEeSZGsrO_8UE3g"/> + <edges xmi:type="notation:Connector" xmi:id="_XbJ9kAFpEeSZGsrO_8UE3g" type="1013" source="_UPsuMAFpEeSZGsrO_8UE3g" target="_P0aOoAFpEeSZGsrO_8UE3g"> + <styles xmi:type="notation:FontStyle" xmi:id="_XbJ9kQFpEeSZGsrO_8UE3g"/> + <element xmi:type="uml:Extension" href="pets.profile.uml#_XbD28QFpEeSZGsrO_8UE3g"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_XbJ9kgFpEeSZGsrO_8UE3g" points="[0, -5, -22, 143]$[16, -123, -6, 25]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_XbiYEAFpEeSZGsrO_8UE3g" id="(0.44,0.0)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Y1OH0AFpEeSZGsrO_8UE3g" id="(0.25,1.0)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_X9-WwAFpEeSZGsrO_8UE3g" type="1013" source="_U4howQFpEeSZGsrO_8UE3g" target="_P0aOoAFpEeSZGsrO_8UE3g"> + <styles xmi:type="notation:FontStyle" xmi:id="_X9-WwQFpEeSZGsrO_8UE3g"/> + <element xmi:type="uml:Extension" href="pets.profile.uml#_X94QIQFpEeSZGsrO_8UE3g"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_X9-WwgFpEeSZGsrO_8UE3g" points="[-15, -11, 174, 137]$[-180, -140, 9, 8]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_X-EdYAFpEeSZGsrO_8UE3g" id="(0.21,0.0)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_X-EdYQFpEeSZGsrO_8UE3g" id="(0.72,1.0)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_Yh140AFpEeSZGsrO_8UE3g" type="1013" source="_VppjsQFpEeSZGsrO_8UE3g" target="_P0aOoAFpEeSZGsrO_8UE3g"> + <styles xmi:type="notation:FontStyle" xmi:id="_Yh140QFpEeSZGsrO_8UE3g"/> + <element xmi:type="uml:Extension" href="pets.profile.uml#_YhprkQFpEeSZGsrO_8UE3g"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Yh140gFpEeSZGsrO_8UE3g" points="[-19, -7, 372, 138]$[-377, -139, 14, 6]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_YiCGEAFpEeSZGsrO_8UE3g" id="(0.11,0.0)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_YiCGEQFpEeSZGsrO_8UE3g" id="(1.0,1.0)"/> + </edges> + </notation:Diagram> + <css:ModelStyleSheets xmi:id="_LT0_YAFpEeSZGsrO_8UE3g"/> +</xmi:XMI> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.uml b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.uml new file mode 100644 index 00000000000..8f7621f5a44 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/pets.profile.uml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Profile xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_KRbHMAFpEeSZGsrO_8UE3g" name="pets" metaclassReference="_P0UIAAFpEeSZGsrO_8UE3g"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ZzBM0AFpEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <contents xmi:type="ecore:EPackage" xmi:id="_d1dnMQFsEeSZGsrO_8UE3g" name="pets" nsURI="http:///schemas/pets/_d1dnMAFsEeSZGsrO_8UE3g/1" nsPrefix="pets"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_d1dnQQFsEeSZGsrO_8UE3g" source="PapyrusVersion"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d1dnQgFsEeSZGsrO_8UE3g" key="Version" value="0.0.2"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d1dnQwFsEeSZGsrO_8UE3g" key="Comment" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d1dnRAFsEeSZGsrO_8UE3g" key="Copyright" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d1dnRQFsEeSZGsrO_8UE3g" key="Date" value="2014-07-02"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d1dnRgFsEeSZGsrO_8UE3g" key="Author" value=""/> + </eAnnotations> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_d1dnMgFsEeSZGsrO_8UE3g" name="Cat"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_d1dnMwFsEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_UPmnkAFpEeSZGsrO_8UE3g"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_d1dnNAFsEeSZGsrO_8UE3g" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_d1dnNgFsEeSZGsrO_8UE3g" name="Dog"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_d1dnNwFsEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_U4howAFpEeSZGsrO_8UE3g"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_d1dnOAFsEeSZGsrO_8UE3g" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_d1dnOgFsEeSZGsrO_8UE3g" name="Bird"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_d1dnOwFsEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_VppjsAFpEeSZGsrO_8UE3g"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_d1dnPAFsEeSZGsrO_8UE3g" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + </contents> + <contents xmi:type="ecore:EPackage" xmi:id="_ZzBM0QFpEeSZGsrO_8UE3g" name="profile" nsURI="http:///schemas/profile/_Zy7GMAFpEeSZGsrO_8UE3g/0" nsPrefix="profile"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ZzBM4QFpEeSZGsrO_8UE3g" source="PapyrusVersion"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZzBM4gFpEeSZGsrO_8UE3g" key="Version" value="0.0.1"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZzBM4wFpEeSZGsrO_8UE3g" key="Comment" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZzBM5AFpEeSZGsrO_8UE3g" key="Copyright" value=""/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZzBM5QFpEeSZGsrO_8UE3g" key="Date" value="2014-07-01"/> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ZzBM5gFpEeSZGsrO_8UE3g" key="Author" value=""/> + </eAnnotations> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_ZzBM0gFpEeSZGsrO_8UE3g" name="Cat"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ZzBM0wFpEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_UPmnkAFpEeSZGsrO_8UE3g"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_ZzBM1AFpEeSZGsrO_8UE3g" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_ZzBM1gFpEeSZGsrO_8UE3g" name="Dog"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ZzBM1wFpEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_U4howAFpEeSZGsrO_8UE3g"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_ZzBM2AFpEeSZGsrO_8UE3g" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xmi:type="ecore:EClass" xmi:id="_ZzBM2gFpEeSZGsrO_8UE3g" name="Bird"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ZzBM2wFpEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_VppjsAFpEeSZGsrO_8UE3g"/> + <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_ZzBM3AFpEeSZGsrO_8UE3g" name="base_Class" ordered="false" lowerBound="1"> + <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/> + </eStructuralFeatures> + </eClassifiers> + </contents> + </eAnnotations> + <elementImport xmi:type="uml:ElementImport" xmi:id="_P0UIAAFpEeSZGsrO_8UE3g" alias="Class"> + <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </elementImport> + <packagedElement xmi:type="uml:Stereotype" xmi:id="_UPmnkAFpEeSZGsrO_8UE3g" name="Cat"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_XbD28AFpEeSZGsrO_8UE3g" name="base_Class" association="_XbD28QFpEeSZGsrO_8UE3g"> + <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </ownedAttribute> + </packagedElement> + <packagedElement xmi:type="uml:Stereotype" xmi:id="_U4howAFpEeSZGsrO_8UE3g" name="Dog"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_X94QIAFpEeSZGsrO_8UE3g" name="base_Class" association="_X94QIQFpEeSZGsrO_8UE3g"> + <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </ownedAttribute> + </packagedElement> + <packagedElement xmi:type="uml:Stereotype" xmi:id="_VppjsAFpEeSZGsrO_8UE3g" name="Bird"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_YhprkAFpEeSZGsrO_8UE3g" name="base_Class" association="_YhprkQFpEeSZGsrO_8UE3g"> + <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/> + </ownedAttribute> + </packagedElement> + <packagedElement xmi:type="uml:Extension" xmi:id="_XbD28QFpEeSZGsrO_8UE3g" name="E_Cat_Class1" memberEnd="_XbD28gFpEeSZGsrO_8UE3g _XbD28AFpEeSZGsrO_8UE3g"> + <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_XbD28gFpEeSZGsrO_8UE3g" name="extension_Cat" type="_UPmnkAFpEeSZGsrO_8UE3g" aggregation="composite" association="_XbD28QFpEeSZGsrO_8UE3g"/> + </packagedElement> + <packagedElement xmi:type="uml:Extension" xmi:id="_X94QIQFpEeSZGsrO_8UE3g" name="E_Dog_Class1" memberEnd="_X94QIgFpEeSZGsrO_8UE3g _X94QIAFpEeSZGsrO_8UE3g"> + <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_X94QIgFpEeSZGsrO_8UE3g" name="extension_Dog" type="_U4howAFpEeSZGsrO_8UE3g" aggregation="composite" association="_X94QIQFpEeSZGsrO_8UE3g"/> + </packagedElement> + <packagedElement xmi:type="uml:Extension" xmi:id="_YhprkQFpEeSZGsrO_8UE3g" name="E_Bird_Class1" memberEnd="_YhprkgFpEeSZGsrO_8UE3g _YhprkAFpEeSZGsrO_8UE3g"> + <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_YhprkgFpEeSZGsrO_8UE3g" name="extension_Bird" type="_VppjsAFpEeSZGsrO_8UE3g" aggregation="composite" association="_YhprkQFpEeSZGsrO_8UE3g"/> + </packagedElement> +</uml:Profile> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.di b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.notation b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.notation new file mode 100644 index 00000000000..7770116fdab --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.notation @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <notation:Diagram xmi:id="_r0aiEAEvEeSR--mxHEXKSA" type="PapyrusUMLClassDiagram" name="NewDiagram" measurementUnit="Pixel"> + <styles xmi:type="notation:StringValueStyle" xmi:id="_r0aiEQEvEeSR--mxHEXKSA" name="diagram_compatibility_version" stringValue="1.0.0"/> + <styles xmi:type="notation:DiagramStyle" xmi:id="_r0aiEgEvEeSR--mxHEXKSA"/> + <styles xmi:type="style:PapyrusViewStyle" xmi:id="_r0aiEwEvEeSR--mxHEXKSA"> + <owner xmi:type="uml:Model" href="testProfile1.uml#_ryIDEAEvEeSR--mxHEXKSA"/> + </styles> + <element xmi:type="uml:Model" href="testProfile1.uml#_ryIDEAEvEeSR--mxHEXKSA"/> + </notation:Diagram> + <notation:Diagram xmi:id="_LT8EAAEwEeSR--mxHEXKSA" type="PapyrusUMLClassDiagram" name="diagram1" measurementUnit="Pixel"> + <children xmi:type="notation:Shape" xmi:id="_MP1rkAEwEeSR--mxHEXKSA" type="2008"> + <children xmi:type="notation:DecorationNode" xmi:id="_MP1rkgEwEeSR--mxHEXKSA" type="5029"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_MP1rkwEwEeSR--mxHEXKSA" type="7017"> + <styles xmi:type="notation:TitleStyle" xmi:id="_MP7yMAEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_MP7yMQEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_MP7yMgEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_MP7yMwEwEeSR--mxHEXKSA"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_MP7yNAEwEeSR--mxHEXKSA" type="7018"> + <styles xmi:type="notation:TitleStyle" xmi:id="_MP7yNQEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_MP7yNgEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_MP7yNwEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_MP7yOAEwEeSR--mxHEXKSA"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_MP7yOQEwEeSR--mxHEXKSA" type="7019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_MP7yOgEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_MP7yOwEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_MP7yPAEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_MP7yPQEwEeSR--mxHEXKSA"/> + </children> + <element xmi:type="uml:Class" href="testProfile1.uml#_MPE2kAEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_MP1rkQEwEeSR--mxHEXKSA" x="90" y="145"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_O9LbkAEwEeSR--mxHEXKSA" type="2008"> + <children xmi:type="notation:DecorationNode" xmi:id="_O9LbkgEwEeSR--mxHEXKSA" type="5029"/> + <children xmi:type="notation:BasicCompartment" xmi:id="_O9LbkwEwEeSR--mxHEXKSA" type="7017"> + <children xmi:type="notation:Shape" xmi:id="_RbaYkAEwEeSR--mxHEXKSA" type="3012"> + <element xmi:type="uml:Property" href="testProfile1.uml#_RbB-EAEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_RbaYkQEwEeSR--mxHEXKSA"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_O9LblAEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_O9LblQEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_O9LblgEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_O9LblwEwEeSR--mxHEXKSA"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_O9LbmAEwEeSR--mxHEXKSA" type="7018"> + <children xmi:type="notation:Shape" xmi:id="_QVG30AEwEeSR--mxHEXKSA" type="3013"> + <element xmi:type="uml:Operation" href="testProfile1.uml#_QU0j8AEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_QVG30QEwEeSR--mxHEXKSA"/> + </children> + <styles xmi:type="notation:TitleStyle" xmi:id="_O9LbmQEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_O9LbmgEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_O9LbmwEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_O9LbnAEwEeSR--mxHEXKSA"/> + </children> + <children xmi:type="notation:BasicCompartment" xmi:id="_O9LbnQEwEeSR--mxHEXKSA" type="7019"> + <styles xmi:type="notation:TitleStyle" xmi:id="_O9LbngEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:SortingStyle" xmi:id="_O9LbnwEwEeSR--mxHEXKSA"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_O9LboAEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_O9LboQEwEeSR--mxHEXKSA"/> + </children> + <element xmi:type="uml:Class" href="testProfile1.uml#_HEgPIAEwEeSR--mxHEXKSA"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_O9LbkQEwEeSR--mxHEXKSA" x="360" y="150"/> + </children> + <styles xmi:type="notation:StringValueStyle" xmi:id="_LT8EAQEwEeSR--mxHEXKSA" name="diagram_compatibility_version" stringValue="1.0.0"/> + <styles xmi:type="notation:DiagramStyle" xmi:id="_LT8EAgEwEeSR--mxHEXKSA"/> + <styles xmi:type="style:PapyrusViewStyle" xmi:id="_LT8EAwEwEeSR--mxHEXKSA"> + <owner xmi:type="uml:Model" href="testProfile1.uml#_ryIDEAEvEeSR--mxHEXKSA"/> + </styles> + <element xmi:type="uml:Model" href="testProfile1.uml#_ryIDEAEvEeSR--mxHEXKSA"/> + </notation:Diagram> +</xmi:XMI> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.uml b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.uml new file mode 100644 index 00000000000..1e0158956a8 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/models/testProfile1.uml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:house="http:///schemas/house/_Kx8fINeMEeOxVfFeCUP2Mg/1" xmlns:pets="http:///schemas/pets/_d1dnMAFsEeSZGsrO_8UE3g/1" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/house/_Kx8fINeMEeOxVfFeCUP2Mg/1 house.profile.uml#_Kx8fIdeMEeOxVfFeCUP2Mg http:///schemas/pets/_d1dnMAFsEeSZGsrO_8UE3g/1 pets.profile.uml#_d1dnMQFsEeSZGsrO_8UE3g"> + <uml:Model xmi:id="_ryIDEAEvEeSR--mxHEXKSA" name="model"> + <packagedElement xmi:type="uml:Package" xmi:id="_FJ8m8AEwEeSR--mxHEXKSA" name="p1"> + <packagedElement xmi:type="uml:Class" xmi:id="_HEgPIAEwEeSR--mxHEXKSA" name="Class1"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_RbB-EAEwEeSR--mxHEXKSA" name="Attribute1"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_QU0j8AEwEeSR--mxHEXKSA" name="Operation1"/> + </packagedElement> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_MPE2kAEwEeSR--mxHEXKSA" name="Class2"/> + <packagedElement xmi:type="uml:Package" xmi:id="_nx9tkAFhEeSZGsrO_8UE3g" name="p2"> + <packagedElement xmi:type="uml:Class" xmi:id="_qOTNIAFhEeSZGsrO_8UE3g" name="ClassWith1Sterotype"/> + <packagedElement xmi:type="uml:Class" xmi:id="_MmC_wAFqEeSZGsrO_8UE3g" name="ClassWith2Stereotypes"/> + </packagedElement> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_wGo5gAFhEeSZGsrO_8UE3g"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_wHBUAAFhEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="house.profile.uml#_Kx8fIdeMEeOxVfFeCUP2Mg"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="house.profile.uml#_BB8hgNeIEeO9b7Ib8OAaeQ"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_KNP8YAFqEeSZGsrO_8UE3g"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_KN0kIAFqEeSZGsrO_8UE3g" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="pets.profile.uml#_d1dnMQFsEeSZGsrO_8UE3g"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pets.profile.uml#_KRbHMAFpEeSZGsrO_8UE3g"/> + </profileApplication> + </uml:Model> + <house:Building xmi:id="_xnb94AFhEeSZGsrO_8UE3g" base_Class="_qOTNIAFhEeSZGsrO_8UE3g"/> + <pets:Cat xmi:id="_Rt8GoAFqEeSZGsrO_8UE3g" base_Class="_MmC_wAFqEeSZGsrO_8UE3g"/> + <house:Building xmi:id="_RuIT4AFqEeSZGsrO_8UE3g" base_Class="_MmC_wAFqEeSZGsrO_8UE3g"/> +</xmi:XMI> diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/plugin.properties b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/plugin.properties new file mode 100644 index 00000000000..6ff866cded7 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/plugin.properties @@ -0,0 +1,12 @@ +################################################################################# +# Copyright (c) 2013 CEA LIST. +# 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: +# Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation +################################################################################## +pluginName=Profile Drafter Tests (Incubation) +providerName=Eclipse Modeling Project diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/pom.xml b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/pom.xml new file mode 100644 index 00000000000..be21d3c4e53 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/pom.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>org.eclipse.papyrus</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../../../../../../releng/top-pom-main-tests.xml</relativePath> + </parent> + <artifactId>org.eclipse.papyrus.uml.profile.drafter.tests</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <version>1.1.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> +</project>
\ No newline at end of file diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/EclipseProject.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/EclipseProject.java new file mode 100644 index 00000000000..4b5340d7211 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/EclipseProject.java @@ -0,0 +1,217 @@ +package org.eclipse.papyrus.uml.profile.drafter.tests; +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + + +import java.net.URL; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.ExecutionException; + + +/** + * This class allows to create or load an Eclipse Project. + * This is the projects found in the project explorer. + * This class is mainly used in tests. + * + * @author cedric dumoulin + * + */ +public class EclipseProject { + + /** + * The underlying Eclipse project. + * + */ + protected IProject project; + + protected IProgressMonitor monitor = new NullProgressMonitor(); + + /** + * Constructor. + * Create or load the specified project. + * @throws ExecutionException + */ + public EclipseProject( String projectName ) throws ExecutionException { + // Create the project + initProject(projectName); + } + + /** + * Create or load the project. + * + * @param projectName + * @throws ExecutionException + */ + protected void initProject(String projectName ) throws ExecutionException { + project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + + if( project == null) { + throw new ExecutionException("Can't get project '" + projectName + "' from workspace."); + } + + if(project != null && !project.exists()) { +// IProgressMonitor monitor = new NullProgressMonitor(); + try { + project.create(monitor); + } catch (CoreException e) { + throw new ExecutionException("Can't create project '" + projectName + "'.", e); + } + } + + if(!project.isOpen()) { + try { + project.open(null); + } catch (CoreException e) { + throw new ExecutionException("Can't open project '" + projectName + "'.", e); + } + } + + + + } + + + /** + * @return the project + */ + public IProject getProject() { + return project; + } + + /** + * + * @param fromBundle + * @param fromResourceName + * @param toResourceName + * @return + * @throws ExecutionException + */ + public IFile copyResource( String fromBundle, String fromResourceName, String toResourceName) throws ExecutionException { + + try { + Path toURL = new Path(toResourceName); +// System.out.println(toURL); + + IFile file = project.getFile(toResourceName); + // link all the models resources + if(!file.exists()) { + // Create intermediate folders + ensureFolders(file); + + URL url = FileLocator.find(Platform.getBundle(fromBundle), new Path(fromResourceName), null); + URL newFile = FileLocator.resolve(url); + + // encode the URI for spaces in the path + // And then create a link to the file + file.createLink(new URL(newFile.toString().replaceAll(" ", "%20")).toURI(), IResource.REPLACE, monitor); + } + return file; + } catch (Exception e) { + throw new ExecutionException("Can't copy resource '" + toResourceName + "'.", e); + } + } + + /** + * Copy the specified resource from the specified bundle to this project. + * Use the same path in src and target. + * + * @param fromBundle + * @param fromResourceName + * @return + * @throws ExecutionException + */ + public IFile copyResource( String fromBundle, String fromResourceName) throws ExecutionException { + + return copyResource(fromBundle, fromResourceName, fromResourceName); + } + + /** + * + * @param fromBundle + * @param fromResourceNames + * @throws ExecutionException + */ + public void copyResources(String fromBundle, String ...fromResourceNames) throws ExecutionException { + + for(String fromResourceName : fromResourceNames) { + copyResource(fromBundle, fromResourceName); + } + } + + /** + * Ensure that the intermediates folders exist in the project. + * + * @param project + * @param name + * @throws CoreException + */ + protected void ensureFolders(IFile file) throws CoreException { + + IPath path = file.getProjectRelativePath(); + IPath folderPath = path.removeLastSegments(1); + + String[] segments = folderPath.segments(); + + for( int i = segments.length-1; i>=0; i--) { + IPath curFolderPath = folderPath.removeLastSegments(i); + createFolder(curFolderPath); + } + + + } + + /** + * + * @param folderPath + * @throws CoreException + */ + private void createFolder(IPath folderPath) throws CoreException { + IFolder parent = project.getFolder(folderPath); + if(!parent.exists()) { + parent.create(true, true, monitor); + } + assert (parent.exists()); } + + /** + * Creates all the folders that are needed to contains the resource. + * + * @param modelName + * @throws ExecutionException + */ + public void createFolders(String modelName) throws ExecutionException { + try { + IFile file = project.getFile(modelName); + // link all the models resources + if(!file.exists()) { + // Create intermediate folders + ensureFolders(file); + } + } catch (CoreException e) { + throw new ExecutionException("Can't create intermediate folders for '" + modelName + ". ", e); + } + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/ModelSetManager.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/ModelSetManager.java new file mode 100644 index 00000000000..e2ca92f7a5e --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/ModelSetManager.java @@ -0,0 +1,268 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.infra.core.resource.ModelMultiException; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel; +import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel; +import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModelUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.NotFoundException; +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.TestUtilsException; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Namespace; +import org.eclipse.uml2.uml.Package; + + +/** + * Class allowing to create a ModelSet, and to query object or models. + * + * @author cedric dumoulin + * + */ +public class ModelSetManager { + + + public static int NOTATION_MODEL = 0x0001; + public static int UML_MODEL = 0x0002; + public static int SASH_MODEL = 0x0004; + public static int ALL_MODEL = 0xFFFF; + + protected ModelSet modelSet; + + /** + * + * Constructor. + * + * @param file + * @throws DraftProfileException + */ + public ModelSetManager( IFile file ) throws TestUtilsException { + + this(file, ALL_MODEL); + } + + /** + * + * Constructor. + * + * @param projectModelPath Path of the model to load. Must contains the project name. + * + * @throws DraftProfileException + */ + public ModelSetManager( IFile file, int models ) throws TestUtilsException { + URI modelUri = URI.createPlatformResourceURI(file.getFullPath().toString(), true); + try { + loadModelSet(modelUri, models); + } catch (ModelMultiException e) { + throw new TestUtilsException(e); + } + } + + /** + * + * Constructor. + * + * @param projectModelPath + * @throws DraftProfileException + */ + public ModelSetManager( String projectModelPath ) throws TestUtilsException { + this(projectModelPath, ALL_MODEL); + } + + /** + * + * Constructor. + * + * @param projectModelPath Path of the model to load. Must contains the project name. + * + * @throws DraftProfileException + */ + public ModelSetManager( String projectModelPath, int models ) throws TestUtilsException { + URI modelUri = URI.createPlatformResourceURI(projectModelPath, true); + try { + loadModelSet(modelUri, models); + } catch (ModelMultiException e) { + throw new TestUtilsException(e); + } + } + + /** + * + * Constructor. + * + * @param modelUri + * @throws DraftProfileException + */ + public ModelSetManager(URI modelUri) throws TestUtilsException { + + this(modelUri, ALL_MODEL); + } + + /** + * + * Constructor. + * + * @param modelUri {@link URI} of the model to load. Must contains the project name. + * @param models bitwise of requested models ( ex: UML_MODEL & DI_MODEL ) + * @throws DraftProfileException + */ + public ModelSetManager(URI modelUri, int models) throws TestUtilsException { + try { + loadModelSet(modelUri, models); + } catch (ModelMultiException e) { + throw new TestUtilsException(e); + } + } + + /** + * @return the modelSet + */ + public ModelSet getModelSet() { + return modelSet; + } + + /** + * + * @param modelUri + * @throws ModelMultiException + */ + protected void loadModelSet(URI modelUri, int models ) throws ModelMultiException { + // Create ModelSet and Model + modelSet = new ModelSet(); + + // registers models + if( (models & UML_MODEL)>1 ) { + UmlModel umlModel = new UmlModel(); + modelSet.registerModel(umlModel); + } + if( (models & NOTATION_MODEL)>1 ) { + NotationModel notationModel = new NotationModel(); + modelSet.registerModel(notationModel); + } + if( (models & SASH_MODEL)>1 ) { + DiModel diModel = new DiModel(); + modelSet.registerModel(diModel); + } + + // Do load resources + modelSet.loadModels(modelUri); + } + + /** + * + * @return + * @throws NotFoundException + */ + public UmlModel getUmlModel() throws NotFoundException { + UmlModel model = UmlUtils.getUmlModel(modelSet); + if(model == null) { + throw new NotFoundException("UmlModel not found in ModelSet."); + } + return model; + } + + public NotationModel getNotationModel() throws NotFoundException { + NotationModel model = NotationUtils.getNotationModel(modelSet); + if(model == null) { + throw new NotFoundException("NotationModel not found in ModelSet."); + } + return model; + } + + public SashModel getSashModel() throws NotFoundException { + SashModel model = SashModelUtils.getSashModel(modelSet); + if(model == null) { + throw new NotFoundException("UmlModel not found in ModelSet."); + } + return model; + } + + /** + * Get an element by its qualified name. + * Start search from the root model excluded. + * + * @param qualifiedName + * @return + * @throws NotFoundException + */ + public NamedElement getNamedElementByName( String qualifiedName ) throws NotFoundException { + + UmlModel model = getUmlModel(); + Package modelRoot; + try { + modelRoot = (Package)model.lookupRoot(); + } catch (org.eclipse.papyrus.infra.core.resource.NotFoundException e) { + throw new NotFoundException("Can't find model root", e); + } + + return getNamedElementByName(modelRoot, qualifiedName); + } + + /** + * Get a named element by its qualified name. Lookup from the specified {@link Namespace} excluded. + * + * @param namespace The namespace from which lookup is started. first segment of qualified name is searched inside this namespace. + * + * @param qualifiedName The name of the element searched + * @return The requested element + * @throws NotFoundException If the element is not found. + */ + public NamedElement getNamedElementByName( Namespace namespace, String qualifiedName ) throws NotFoundException { + if( qualifiedName == null || qualifiedName.length() == 0) { + throw new NotFoundException("QualifiedName is empty"); + } + + String path[] = qualifiedName.split("::"); + + NamedElement namedElement = namespace; + for( int i=0; i<path.length; i++) { + // lookup subelement + if( namedElement instanceof Package ) { + Package p = (Package)namedElement; + namedElement = p.getPackagedElement(path[i], true, null, false); + } + else if( namedElement instanceof Namespace ) { + Namespace n = (Namespace)namedElement; + namedElement = n.getMember(path[i], true, null); + } + else { + throw new NotFoundException("Element '" + qualifiedName + "' not found." + + " Element '" + namedElement.getQualifiedName() + + "' do not contains '" + path[i] + "'"); + } + } + + // Return element + return namedElement; + } + + /** + * Dispose the ModelSet. + * Object should not be used anymore after dispose. + */ + public void dispose() { + if(modelSet != null) { + modelSet.unload(); + modelSet = null; + } + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/TracesRecorder.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/TracesRecorder.java new file mode 100644 index 00000000000..7d796e9b190 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/TracesRecorder.java @@ -0,0 +1,143 @@ +/******************************************************************************* + * Copyright (c) 2013 CEA LIST. + * 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: + * Cedric Dumoulin - cedric.dumoulin@lifl.fr + ******************************************************************************/ +package org.eclipse.papyrus.uml.profile.drafter.tests; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.notify.Notification; + + +/** + * This class is used to record a list of traces. + * Traces are for event triggered by a method. + * This class is for tests purpose. + * + * @author cedric dumoulin + * + */ +public class TracesRecorder<T1, T2> { + + + /** + * List of recorded events + */ + public List<TraceRecord<T1, T2>> traces = new ArrayList<TraceRecord<T1, T2>>(); + + /** + * Clear all traces. + */ + public void clear() { + traces.clear(); + } + + /** + * Add a trace to the list of traces + * @param name + * @param notification + */ + public void records(String name, T1 obj1) { + traces.add(new TraceRecord<T1, T2>(name, obj1)); + } + + /** + * Add a trace to the list of traces + * @param name + * @param notification + */ + public void records(String name, T1 obj1, T2 obj2) { + traces.add(new TraceRecord<T1, T2>(name, obj1, obj2)); + } + + /** + * Return true if one of the trace has the specified name. + * @param name + * @return + */ + public boolean contains(String name) { + if( name == null) + return false; + + for(TraceRecord<T1, T2> event : traces) { + if(name.equals(event.name)) + return true; + } + return false; + } + + /** + * Return true if one of the trace has the specified name. + * @param name Name of the event to found + * @return the first event with the specified name, or null if nothing is found. + */ + public TraceRecord<T1, T2> getFirstEvent(String name) { + if( name == null) + return null; + + for(TraceRecord<T1, T2> event : traces) { + if(name.equals(event.name)) + return event; + } + return null; + } + + + /** + * A record of an event + * + */ + public class TraceRecord<T1, T2> { + public String name; + public T1 obj1; + public T2 obj2; + + /** + * Constructor. + * + * @param name + * @param notifier + */ + public TraceRecord(String name, T1 notifier) { + this.name = name; + this.obj1 = notifier; + } + /** + * Constructor. + * + * @param name + * @param object + */ + public TraceRecord(String name, T1 obj1, T2 obj2) { + this.name = name; + this.obj1 = obj1; + this.obj2 = obj2; + } + + } + + + /** + * Return the number of traces + * @return + */ + public int size() { + return traces.size(); + } + + /** + * Get the specified trace. + * @param i + * @return + */ + public TraceRecord<T1, T2> get(int index) { + return traces.get(index); + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/ExecutionException.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/ExecutionException.java new file mode 100644 index 00000000000..affca6180e0 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/ExecutionException.java @@ -0,0 +1,83 @@ +/***************************************************************************** + * Copyright (c) 2013 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.exception; + + +/** + * Root exception of the package. + * + * @author cedric dumoulin + * + */ +public class ExecutionException extends TestUtilsException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + */ + public ExecutionException() { + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + */ + public ExecutionException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param cause + */ + public ExecutionException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public ExecutionException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + * @param enableSuppression + * @param writableStackTrace + */ + public ExecutionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + // TODO Auto-generated constructor stub + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/NotFoundException.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/NotFoundException.java new file mode 100644 index 00000000000..6ce2884a4b7 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/NotFoundException.java @@ -0,0 +1,81 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.exception; + + +/** + * @author dumoulin + * + */ +public class NotFoundException extends TestUtilsException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + */ + public NotFoundException() { + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + */ + public NotFoundException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param cause + */ + public NotFoundException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public NotFoundException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + * @param enableSuppression + * @param writableStackTrace + */ + public NotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + // TODO Auto-generated constructor stub + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/TestUtilsException.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/TestUtilsException.java new file mode 100644 index 00000000000..e629a8d5a8d --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/exception/TestUtilsException.java @@ -0,0 +1,83 @@ +/***************************************************************************** + * Copyright (c) 2013 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.exception; + + +/** + * Root exception of the package. + * + * @author cedric dumoulin + * + */ +public class TestUtilsException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + */ + public TestUtilsException() { + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + */ + public TestUtilsException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param cause + */ + public TestUtilsException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public TestUtilsException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + * @param enableSuppression + * @param writableStackTrace + */ + public TestUtilsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + // TODO Auto-generated constructor stub + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/utils/UMLModelCreator.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/utils/UMLModelCreator.java new file mode 100644 index 00000000000..74a4c377929 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/src/org/eclipse/papyrus/uml/profile/drafter/tests/utils/UMLModelCreator.java @@ -0,0 +1,210 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.utils; + +import org.eclipse.emf.common.util.URI; +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.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.DataType; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.resource.UMLResource; + + +/** + * Class use to create a UML Model inside a Resource, and to populate it. + * + * @author cedric dumoulin + * + */ +public class UMLModelCreator { + + protected Resource resource; + + protected Package curPackage; + + /** + * + * Constructor. + * + * @param resourceUri + */ + public UMLModelCreator(String resourceUri, String rootModelName) { + + resource = createResource(resourceUri); + + Model model = createRootModel(rootModelName); + resource.getContents().add(model); + cd(model); + } + + + + + + /** + * + * Constructor. + * + * @param resource + * @throws IllegalAccessException + */ + public UMLModelCreator(Resource resource) throws IllegalArgumentException { + this.resource = resource; + + // Lookup for a Pacakge ine the resource. + Package p = (Package)EcoreUtil.getObjectByType(resource.getContents(),UMLPackage.eINSTANCE.getPackage()); + if( p == null) { + p = (Model)EcoreUtil.getObjectByType(resource.getContents(),UMLPackage.eINSTANCE.getModel()); + } + if( p == null) { + throw new IllegalArgumentException("Resource must contains a Package or a Model"); + } + cd(p); + } + + /** + * + * @return + */ + private Resource createResource(String uriName) { + ResourceSet resourceSet = new ResourceSetImpl(); + + // True for local test, false for plugin test + if(true) { + // Register the default resource factory -- only needed for stand-alone! + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( + Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( + UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE ); + + } + + URI uri = URI.createURI(uriName); + Resource resource = resourceSet.createResource(uri); + + return resource; + } + + /** + * @param rootModelName + * @return + */ + private Model createRootModel(String rootModelName) { + Model model = UMLFactory.eINSTANCE.createModel(); + model.setName(rootModelName); + return model; + } + + /** + * Change current package to specified package. + * The package should belong to the Resource (not verified). + * + * @param p + */ + public void cd(Package p) { + curPackage = p; + } + + /** + * Change current package to the root model. + * + * @param p + */ + public Package cdToRoot() { + // Lookup for a Pacakge ine the resource. + Package p = (Package)EcoreUtil.getObjectByType(resource.getContents(),UMLPackage.eINSTANCE.getPackage()); + if( p == null) { + p = (Model)EcoreUtil.getObjectByType(resource.getContents(),UMLPackage.eINSTANCE.getModel()); + } + + return p; + } + + public Class createClass( String name ) { + Class c = UMLFactory.eINSTANCE.createClass(); + c.setName(name); + curPackage.getPackagedElements().add(c); + return c; + } + + public DataType createDatatype( String name ) { + DataType c = UMLFactory.eINSTANCE.createDataType(); + c.setName(name); + curPackage.getPackagedElements().add(c); + return c; + } + + public Package createPackage( String name ) { + return createPackage(name, true); + } + + public Model createModel( String name ) { + return createModel(name, true); + } + + /** + * + * @param name + * @param changeCurrent + * @return + */ + public Package createPackage( String name, boolean changeCurrent ) { + Package c = UMLFactory.eINSTANCE.createModel(); + c.setName(name); + curPackage.getNestedPackages().add(c); + if( changeCurrent ) { + curPackage = c; + } + return c; + } + + /** + * + * @param name + * @param changeCurrent + * @return + */ + public Model createModel( String name, boolean changeCurrent ) { + Model c = UMLFactory.eINSTANCE.createModel(); + c.setName(name); + curPackage.getNestedPackages().add(c); + if( changeCurrent ) { + curPackage = c; + } + return c; + } + + /** + * Return the current Package. + * + * @return + */ + public Package getCurrentDir() { + return curPackage; + } + + public Resource getResource() { + return resource; + } + + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ProfileCatalogTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ProfileCatalogTest.java new file mode 100644 index 00000000000..b041f1f0072 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ProfileCatalogTest.java @@ -0,0 +1,335 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertSame; + +import java.util.List; + +import org.eclipse.papyrus.uml.profile.drafter.exceptions.NotFoundException; +import org.eclipse.papyrus.uml.profile.drafter.tests.EclipseProject; +import org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager; +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.TestUtilsException; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Profile; +import org.eclipse.uml2.uml.Stereotype; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * @author cedric dumoulin + * + */ +public class ProfileCatalogTest { + + /** + * Name of the project that is created. + */ + static protected String PROJECT_NAME = "org.eclipse.papyrus.uml.profile.drafter.teststemp"; + + /** + * Plugin from which resources are copied. + */ + static protected String FROM_PROJECT_NAME = "org.eclipse.papyrus.uml.profile.drafter.tests"; + + /** + * Prefix name of the resources + */ + static protected String TEST_MODEL_1 = "models/testProfile1"; + + /** + * Prefix name of the resources + */ + static protected String PROFILE1_MODEL = "models/house.profile"; + static protected String PROFILE2_MODEL = "models/pets.profile"; + + /** + * Full name of the di resource, in project. + */ + static protected String MODEL_1_FULLPATH = "/" +PROJECT_NAME + "/" + TEST_MODEL_1 + ".di"; + + static protected String profileHouseName = "house"; + static protected String stereotypeBuildingName = "Building"; + + static protected String profilePetsName = "pets"; + static protected String stereotypeCatName = "Cat"; + static protected String stereotypeDogName = "Dog"; + + static protected int profilesCount = 2; + static protected int stereotypeCount = 7; + static protected int stereotypeForClassCount = 6; + + /** + * Created project. + */ + static protected EclipseProject project; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + // Copy resources from plugin to a new project + project = new EclipseProject(PROJECT_NAME); + project.copyResources(FROM_PROJECT_NAME, TEST_MODEL_1 + ".di", TEST_MODEL_1 + ".uml", TEST_MODEL_1 + ".notation" ); + + // Copy sterotype. + project.copyResources(FROM_PROJECT_NAME, PROFILE1_MODEL + ".di", PROFILE1_MODEL + ".uml", PROFILE1_MODEL + ".notation" ); + project.copyResources(FROM_PROJECT_NAME, PROFILE2_MODEL + ".di", PROFILE2_MODEL + ".uml", PROFILE2_MODEL + ".notation" ); + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#ProfileCatalog(org.eclipse.uml2.uml.Element)}. + * @throws TestUtilsException + */ + @Test + public void testProfileCatalog() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + assertNotNull("Catalog is created", catalog); + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getNamedElement()}. + * @throws TestUtilsException + */ + @Test + public void testGetNamedElement() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + assertNotNull("Catalog is created", catalog); + assertNotNull("NamedElement is found", catalog.getNamedElement()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#lookupStereotype(java.lang.String, java.lang.String)}. + * @throws TestUtilsException + * @throws NotFoundException + */ + @Test + public void testLookupStereotype() throws TestUtilsException, NotFoundException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + Stereotype stereotype = catalog.lookupStereotype(profileHouseName, stereotypeBuildingName); + assertNotNull("Stereotype found", stereotype); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#lookupStereotypeInAppliedProfile(java.lang.String, java.lang.String)}. + * @throws org.eclipse.papyrus.uml.profile.drafter.tests.exception.NotFoundException + * @throws TestUtilsException + */ + @Test + public void testLookupStereotypeInAppliedProfile() throws NotFoundException, TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + Stereotype stereotype = catalog.lookupStereotypeInAppliedProfile(profileHouseName, stereotypeBuildingName); + assertNotNull("Stereotype found", stereotype); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getProfiles()}. + * @throws TestUtilsException + */ + @Test + public void testGetProfiles() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + List<Profile> profiles = catalog.getProfiles(); + assertNotNull("Profiles found", profiles); + assertTrue("Profiles is not empty", ! profiles.isEmpty()); + assertSame("Profiles count", profilesCount, profiles.size() ); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getStereotypes()}. + * @throws TestUtilsException + */ + @Test + public void testGetStereotypes() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + List<Stereotype> stereotypes = catalog.getStereotypes(); + assertNotNull("Stereotype found", stereotypes); + assertTrue("Stereotype is not empty", ! stereotypes.isEmpty()); + assertSame("Stereotype count", stereotypeCount, stereotypes.size() ); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getProfileNames()}. + * @throws TestUtilsException + */ + @Test + public void testGetProfileNames() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + List<String> profileNames = catalog.getProfileNames(); + assertNotNull("Profile found", profileNames); + assertTrue("Profile is not empty", ! profileNames.isEmpty()); + assertSame("Profile count", profilesCount, profileNames.size() ); + assertTrue("Profile found", profileNames.contains(profileHouseName)); + assertTrue("Profile found", profileNames.contains(profilePetsName)); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getStereotypeNames()}. + * @throws TestUtilsException + */ + @Test + public void testGetStereotypeNames() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + List<String> stereotypes = catalog.getStereotypeNames(); + assertNotNull("Stereotype found", stereotypes); + assertTrue("Stereotype is not empty", ! stereotypes.isEmpty()); + assertSame("Stereotype count", stereotypeCount, stereotypes.size() ); + assertTrue("Stereotype found", stereotypes.contains(stereotypeBuildingName)); + assertTrue("Stereotype found", stereotypes.contains(stereotypeDogName)); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getProfileQualifiedNames()}. + * @throws TestUtilsException + */ + @Test + public void testGetProfileQualifiedNames() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + List<String> names = catalog.getProfileQualifiedNames(); + assertNotNull("Names found", names); + assertTrue("Names is not empty", ! names.isEmpty()); + assertSame("Names count", profilesCount, names.size() ); + assertTrue("Name found", names.contains(profileHouseName)); + assertTrue("Name found", names.contains(profilePetsName)); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getStereotypeQualifiedNames()}. + * @throws TestUtilsException + */ + @Test + public void testGetStereotypeQualifiedNames() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + + ProfileCatalog catalog = new ProfileCatalog(namedElement); + + List<String> names = catalog.getStereotypeQualifiedNames(); + assertNotNull("Names found", names); + assertTrue("Names is not empty", ! names.isEmpty()); + assertSame("Names count", stereotypeCount, names.size() ); + assertTrue("Name found", names.contains(profileHouseName + "::" + stereotypeBuildingName)); + assertTrue("Name found", names.contains(profilePetsName + "::" + stereotypeDogName)); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ProfileCatalog#getAllStereotypeNames()}. + */ + @Test + @Ignore + public void testGetAllStereotypeNames() { + fail("Not yet implemented"); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#getNamedElementByName(java.lang.String)}. + * Test Stereotype access. + * + * @throws TestUtilsException + */ + @Test + public void testIsModelsExist() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + assertNotNull("Class found", namedElement); + assertTrue("Right Class found", namedElement instanceof org.eclipse.uml2.uml.Class); + + // Chack sterotype + List<Stereotype> stereotypes = namedElement.getAppliedStereotypes(); + assertTrue("Stereotype applied", !stereotypes.isEmpty()); + assertNotNull("Stereotype found", namedElement.getAppliedStereotype("house::Building") ); + } + + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/AllTests.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/AllTests.java new file mode 100644 index 00000000000..7f91ac01b48 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/AllTests.java @@ -0,0 +1,47 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.profile.drafter.tests; + + +import org.eclipse.papyrus.uml.profile.drafter.ProfileCatalogTest; +import org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreatorTest; +import org.eclipse.papyrus.uml.profile.drafter.ui.model.CompoundTypeProviderTest; +import org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitorTest; +import org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURLTest; +import org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProviderTest; +import org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProviderTest2; +import org.eclipse.papyrus.uml.profile.drafter.utils.UMLPrimitiveTypesModelTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Test suite for this fragment + */ +@RunWith(Suite.class) +@SuiteClasses({ + ProfileCatalogTest.class, + EclipseProjectTest.class, + ModelSetManagerTest.class, + UMLModelCreatorTest.class, + CompoundTypeProviderTest.class, + SimpleModelVisitorTest.class, + StereotypeURLTest.class, + TypeProviderTest.class, + TypeProviderTest2.class, + UMLPrimitiveTypesModelTest.class +}) +public class AllTests { + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/EclipseProjectTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/EclipseProjectTest.java new file mode 100644 index 00000000000..d48f45dee62 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/EclipseProjectTest.java @@ -0,0 +1,110 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests; + +import static org.junit.Assert.*; + +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.ExecutionException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * @author cedric dumoulin + * + */ +public class EclipseProjectTest { + + private static final String PROJECT_NAME = "org.eclipse.papyrus.uml.profile.drafter.teststemp"; + private static final String FROM_BUNDLE_NAME = "org.eclipse.papyrus.uml.profile.drafter.tests"; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#EclipseProject(java.lang.String)}. + * @throws ExecutionException + */ + @Test + public void testEclipseProject() throws ExecutionException { + EclipseProject project = new EclipseProject(PROJECT_NAME); + + assertNotNull( "object created", project); + } + + /** + * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#getProject()}. + * @throws ExecutionException + */ + @Test + public void testGetProject() throws ExecutionException { + EclipseProject project = new EclipseProject(PROJECT_NAME); + + assertNotNull( "object created", project.getProject()); + + } + + /** + * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#copyResource(java.lang.String, java.lang.String, java.lang.String)}. + * @throws ExecutionException + */ + @Test + public void testCopyResource() throws ExecutionException { + + String fromFile = "META-INF/MANIFEST.MF"; + String toFile = "a/b/META-INF/MANIFEST.MF"; + + EclipseProject project = new EclipseProject(PROJECT_NAME); + + project.copyResource(FROM_BUNDLE_NAME, fromFile, toFile); + + assertNotNull( "file copied", project.getProject().findMember(toFile)); + } + + /** + * Test method for {@link org.eclipse.papyrus.integrationtests.editor.EclipseProject#copyResource(java.lang.String, java.lang.String, java.lang.String)}. + * @throws ExecutionException + */ + @Test + public void testCopyResources() throws ExecutionException { + + String fromFile1 = "META-INF/MANIFEST.MF"; + String fromFile2 = "about.html"; + + EclipseProject project = new EclipseProject(PROJECT_NAME); + + assertNull( "file copied", project.getProject().findMember(fromFile1)); + assertNull( "file copied", project.getProject().findMember(fromFile2)); + + project.copyResources(FROM_BUNDLE_NAME, fromFile1, fromFile2); + + assertNotNull( "file copied", project.getProject().findMember(fromFile1)); + assertNotNull( "file copied", project.getProject().findMember(fromFile2)); + } + + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ModelSetManagerTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ModelSetManagerTest.java new file mode 100644 index 00000000000..d0e561898f1 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ModelSetManagerTest.java @@ -0,0 +1,258 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.uml.profile.drafter.exceptions.DraftProfileException; +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.ExecutionException; +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.NotFoundException; +import org.eclipse.papyrus.uml.profile.drafter.tests.exception.TestUtilsException; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Stereotype; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * @author cedric dumoulin + * + */ +public class ModelSetManagerTest { + + /** + * Name of the project that is created. + */ + static protected String PROJECT_NAME = "org.eclipse.papyrus.uml.profile.drafter.teststemp"; + + /** + * Plugin from which resources are copied. + */ + static protected String FROM_PROJECT_NAME = "org.eclipse.papyrus.uml.profile.drafter.tests"; + + /** + * Prefix name of the resources + */ + static protected String TEST_MODEL_1 = "models/testProfile1"; + + /** + * Prefix name of the resources + */ + static protected String PROFILE1_MODEL = "models/house.profile"; + + /** + * Full name of the di resource, in project. + */ + static protected String MODEL_1_FULLPATH = "/" +PROJECT_NAME + "/" + TEST_MODEL_1 + ".di"; + + /** + * Created project. + */ + static protected EclipseProject project; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + // Copy resources from plugin to a new project + project = new EclipseProject(PROJECT_NAME); + project.copyResources(FROM_PROJECT_NAME, TEST_MODEL_1 + ".di", TEST_MODEL_1 + ".uml", TEST_MODEL_1 + ".notation" ); + + // Copy sterotype. + project.copyResources(FROM_PROJECT_NAME, PROFILE1_MODEL + ".di", PROFILE1_MODEL + ".uml", PROFILE1_MODEL + ".notation" ); + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + // Copy resources from plugin to a new project +// EclipseProject project = new EclipseProject(PROJECT_NAME); +// project.copyResources(FROM_PROJECT_NAME, TEST_MODEL_1 + ".di", TEST_MODEL_1 + ".uml", TEST_MODEL_1 + ".notation" ); + + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#ModelSetManager(java.lang.String)}. + * @throws DraftProfileException + */ + @Test + public void testModelSetManagerString() throws TestUtilsException { + + + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + + // asserts + assertNotNull("object created", modelSetManager); + assertNotNull("modelSet created", modelSetManager.getModelSet()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#ModelSetManager(java.lang.String)}. + * @throws DraftProfileException + */ + @Test + public void testModelSetManagerStringModels() throws TestUtilsException { + + + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH, ModelSetManager.UML_MODEL); + + // asserts + assertNotNull("object created", modelSetManager); + assertNotNull("modelSet created", modelSetManager.getModelSet()); + assertNotNull("uml model created", modelSetManager.getUmlModel()); + + try { + modelSetManager.getNotationModel(); + fail("Notation model should not be created"); + } catch (NotFoundException e) { + // ok + } + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#ModelSetManager(org.eclipse.emf.common.util.URI)}. + * @throws DraftProfileException + */ + @Test + public void testModelSetManagerURI() throws TestUtilsException { + + URI uri = URI.createPlatformResourceURI(MODEL_1_FULLPATH, true); + ModelSetManager modelSetManager = new ModelSetManager(uri); + + // asserts + assertNotNull("object created", modelSetManager); + assertNotNull("modelSet created", modelSetManager.getModelSet()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#getUmlModel()}. + * Check if the model is really loaded ! + * @throws NotFoundException + * @throws org.eclipse.papyrus.infra.core.resource.NotFoundException + * @throws DraftProfileException + * @throws ExecutionException + * + */ + @Test + public void testGetUmlModel() throws TestUtilsException, org.eclipse.papyrus.infra.core.resource.NotFoundException { + + EclipseProject project = new EclipseProject(PROJECT_NAME); + project.copyResources(FROM_PROJECT_NAME, TEST_MODEL_1 + ".di", TEST_MODEL_1 + ".uml", TEST_MODEL_1 + ".notation" ); + + ModelSetManager modelSetManager = new ModelSetManager("/" +PROJECT_NAME + "/" + TEST_MODEL_1 + ".di"); + + // asserts + assertNotNull("object created", modelSetManager); + assertNotNull("modelSet created", modelSetManager.getModelSet()); + assertNotNull("UmlModel loaded", modelSetManager.getUmlModel()); + assertNotNull("UmlModel root found", modelSetManager.getUmlModel().lookupRoot()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#getUmlModel()}. + * Check if the model is really loaded ! + * @throws NotFoundException + * @throws org.eclipse.papyrus.infra.core.resource.NotFoundException + * @throws DraftProfileException + * @throws ExecutionException + * + */ + @Test + public void testGetUmlModelWithIFile() throws TestUtilsException, org.eclipse.papyrus.infra.core.resource.NotFoundException { + + EclipseProject project = new EclipseProject(PROJECT_NAME); + project.copyResources(FROM_PROJECT_NAME, TEST_MODEL_1 + ".di", TEST_MODEL_1 + ".uml", TEST_MODEL_1 + ".notation" ); + + + IFile file = project.getProject().getFile(TEST_MODEL_1 + ".di"); + + assertTrue( "file exists", file.exists() ); + ModelSetManager modelSetManager = new ModelSetManager(file); + + // asserts + assertNotNull("object created", modelSetManager); + assertNotNull("modelSet created", modelSetManager.getModelSet()); + assertNotNull("UmlModel loaded", modelSetManager.getUmlModel()); + assertNotNull("UmlModel root found", modelSetManager.getUmlModel().lookupRoot()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#getNamedElementByName(java.lang.String)}. + * @throws TestUtilsException + */ + @Test + public void testGetNamedElementByNameString() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + + String qualifiedName = "p1::Class1"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + assertNotNull("Class found", namedElement); + assertTrue("Right Class found", namedElement instanceof org.eclipse.uml2.uml.Class); + + // + qualifiedName = "p1::Class1::Attribute1"; + namedElement = modelSetManager.getNamedElementByName(qualifiedName); + assertNotNull("Attribute found", namedElement); + assertTrue("Right Type found", namedElement instanceof org.eclipse.uml2.uml.Property); + + } + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.ModelSetManager#getNamedElementByName(java.lang.String)}. + * Test Stereotype access. + * + * @throws TestUtilsException + */ + @Test + public void testGetNamedElementByNameWithSterotype() throws TestUtilsException { + ModelSetManager modelSetManager = new ModelSetManager(MODEL_1_FULLPATH); + + String qualifiedName = "p2::ClassWith1Sterotype"; + NamedElement namedElement = modelSetManager.getNamedElementByName(qualifiedName); + assertNotNull("Class found", namedElement); + assertTrue("Right Class found", namedElement instanceof org.eclipse.uml2.uml.Class); + + // Chack sterotype + List<Stereotype> stereotypes = namedElement.getAppliedStereotypes(); + assertTrue("Stereotype applied", !stereotypes.isEmpty()); + assertNotNull("Stereotype found", namedElement.getAppliedStereotype("house::Building") ); + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/OwnerKind.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/OwnerKind.java new file mode 100644 index 00000000000..ca64e0b3f91 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/OwnerKind.java @@ -0,0 +1,27 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + + +/** + * A fake OwnerKind. + * + * @author dumoulin + * + */ +public enum OwnerKind { + + owned, inherited; +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyCatalog.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyCatalog.java new file mode 100644 index 00000000000..0726b5c86b6 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyCatalog.java @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + +import java.util.ArrayList; +import java.util.List; + + +/** + * A catalog of fake {@link PropertyModel}. + * + * @author dumoulin + * + */ +public class PropertyCatalog { + + /** + * {@link TypeLibrary} used to find Types + */ + protected TypeLibrary typeLibrary; + + protected List<PropertyModel> properties; + + protected void init() { + properties = new ArrayList<PropertyModel>(); + + properties.add(new PropertyModel("p1", typeLibrary.BOOLEAN, OwnerKind.owned)); + properties.add(new PropertyModel("p2", typeLibrary.INT, OwnerKind.owned)); + properties.add(new PropertyModel("p3", typeLibrary.DOUBLE, OwnerKind.owned)); + properties.add(new PropertyModel("p4", typeLibrary.INT, OwnerKind.inherited)); + properties.add(new PropertyModel("p5", typeLibrary.STRING, OwnerKind.owned)); + } + + + /** + * Constructor. + * + * @param typeLibrary TypeLibrary used to find types. + */ + public PropertyCatalog(TypeLibrary typeLibrary) { + this.typeLibrary = typeLibrary; + init(); + } + + /** + * @return the typeLibrary + */ + public TypeLibrary getTypeLibrary() { + return typeLibrary; + } + + + /** + * @param typeLibrary the typeLibrary to set + */ + public void setTypeLibrary(TypeLibrary typeLibrary) { + this.typeLibrary = typeLibrary; + } + + + /** + * @return the properties + */ + public List<PropertyModel> getProperties() { + return properties; + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyModel.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyModel.java new file mode 100644 index 00000000000..476c3bd89e2 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyModel.java @@ -0,0 +1,102 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + + +/** + * @author dumoulin + * + */ +public class PropertyModel { + + protected String name; + protected Type type; + protected OwnerKind ownerKind; + + /** + * Constructor. + * + */ + public PropertyModel() { + // TODO Auto-generated constructor stub + } + + + /** + * Constructor. + * + * @param name + * @param type + * @param ownerKind + */ + public PropertyModel(String name, Type type, OwnerKind ownerKind) { + this.name = name; + this.type = type; + this.ownerKind = ownerKind; + } + + + + /** + * @return the name + */ + public String getName() { + return name; + } + + + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + + + /** + * @return the type + */ + public Type getType() { + return type; + } + + + + /** + * @param type the type to set + */ + public void setType(Type type) { + this.type = type; + } + + + /** + * @return the ownerKind + */ + public OwnerKind getOwnerKind() { + return ownerKind; + } + + + /** + * @param ownerKind the ownerKind to set + */ + public void setOwnerKind(OwnerKind ownerKind) { + this.ownerKind = ownerKind; + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TableViewerExample.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TableViewerExample.java new file mode 100644 index 00000000000..23d18b3dd1e --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TableViewerExample.java @@ -0,0 +1,211 @@ +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + +import java.util.List; + +import org.eclipse.core.databinding.observable.Realm; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; +import org.eclipse.jface.viewers.ICellModifier; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +/** + * Example of a Table with editable cells. + * To be run as Java code + * + * @author cedric dumoulin + * + */ +public class TableViewerExample { + + static String[] COLUMN_NAMES = new String[] { "names", "types", "types2", "owner" }; + static int[] COLUMN_WIDTHS = new int[] { 300, 200, 200, 100 }; + static String[] COLUMNS_PROPERTIES = new String[] { "names_prop", "types_prop", "types2_prop", "owner_prop" }; + + static class ModelContentProvider implements IStructuredContentProvider { + + @SuppressWarnings("unchecked") + @Override + public Object[] getElements(Object inputElement) { + // The inputElement comes from view.setInput() + if (inputElement instanceof List) { + List models = (List) inputElement; + return models.toArray(); + } + return new Object[0]; + } + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + } + + static class ModelLabelProvider extends LabelProvider implements ITableLabelProvider { + + @Override + public Image getColumnImage(Object element, int columnIndex) { + // no image to show + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + // each element comes from the ContentProvider.getElements(Object) + if (!(element instanceof PropertyModel)) { + return ""; + } + PropertyModel model = (PropertyModel) element; + switch (columnIndex) { + case 0: + return model.getName(); + case 1: + return model.getType().getName(); + case 2: + return model.getType().getName(); + case 3: + return model.getOwnerKind().toString(); + default: + break; + } + return ""; + } + } + + static class ModelCellModifier implements ICellModifier { + TableViewer viewer; + + public ModelCellModifier(TableViewer viewer) { + this.viewer = viewer; + } + + @Override + public boolean canModify(Object element, String property) { + // property is defined by viewer.setColumnProperties() + // allow the FOO column can be modified. + return ("names_prop".equals(property) + || "types_prop".equals(property) + || "types2_prop".equals(property) + ); + + } + + @Override + public Object getValue(Object element, String property) { + if ("names_prop".equals(property)) { + return ((PropertyModel) element).getName(); + } + if ("types_prop".equals(property)) { + return ((PropertyModel) element).getType(); + } + if ("types2_prop".equals(property)) { + return ((PropertyModel) element).getType(); + } + return ""; + } + + @Override + public void modify(Object element, String property, Object value) { + if ("names_prop".equals(property)) { + TableItem item = (TableItem) element; + ((PropertyModel) item.getData()).setName("" + value); + + // refresh the viewer to show the changes to our user. + viewer.refresh(); + } + else if ("types_prop".equals(property)) { + TableItem item = (TableItem) element; + System.out.println("modify.type(" + value + ")"); + if( value instanceof Type) { + ((PropertyModel) item.getData()).setType((Type)value); + } + // refresh the viewer to show the changes to our user. + viewer.refresh(); + } + else if ("types2_prop".equals(property)) { + TableItem item = (TableItem) element; + System.out.println("modify.type2(" + value + ")"); + if( value instanceof Type) { + ((PropertyModel) item.getData()).setType((Type)value); + } + // refresh the viewer to show the changes to our user. + viewer.refresh(); + } + } + } + + public static void main(String[] args) { + + final TypeLibrary typeLibrary = new TypeLibrary(); + final PropertyCatalog propertyCatalog = new PropertyCatalog(typeLibrary); + final TypeLabelProvider typeLabelProvider = new TypeLabelProvider(); + + + final ApplicationWindow app = new ApplicationWindow(null) { + @Override + protected Control createContents(Composite parent) { + TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION); + Table table = tableViewer.getTable(); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + for (int i = 0; i < COLUMN_NAMES.length; i++) { + TableColumn tableColumn = new TableColumn(table, SWT.LEFT); + tableColumn.setText(COLUMN_NAMES[i]); + tableColumn.setWidth(COLUMN_WIDTHS[i]); + } + + tableViewer.setContentProvider(new ModelContentProvider()); + tableViewer.setLabelProvider(new ModelLabelProvider()); + + // Create a ComboBoxViewerCellEditor for types + // + ComboBoxViewerCellEditor comboBoxViewerCellEditor = new ComboBoxViewerCellEditor(table); + comboBoxViewerCellEditor.setContentProvider(ArrayContentProvider.getInstance()); + comboBoxViewerCellEditor.setLabelProvider(typeLabelProvider); + comboBoxViewerCellEditor.setInput(typeLibrary.getTypes()); + // Create editor support + tableViewer.setColumnProperties(COLUMNS_PROPERTIES); + tableViewer.setCellEditors(new CellEditor[] { + new TextCellEditor(table), + new TypeSelectorCellEditor(table, typeLibrary, typeLabelProvider), + comboBoxViewerCellEditor + }); + tableViewer.setCellModifier(new ModelCellModifier(tableViewer)); + + tableViewer.setInput(propertyCatalog.getProperties()); + return parent; + } + }; + + Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), + new Runnable() { + @Override + public void run() { + app.setBlockOnOpen(true); + app.open(); + Display.getDefault().dispose(); + } + }); + + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/Type.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/Type.java new file mode 100644 index 00000000000..6c482f73940 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/Type.java @@ -0,0 +1,54 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + + +/** + * A fake type for tests + * + * @author cedric dumoulin + * + */ +public class Type { + + protected String name; + + + /** + * Constructor. + * + * @param name + */ + public Type(String name) { + this.name = name; + } + + + /** + * @return the name + */ + public String getName() { + return name; + } + + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLabelProvider.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLabelProvider.java new file mode 100644 index 00000000000..5324e192f92 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLabelProvider.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + +import org.eclipse.jface.viewers.LabelProvider; + + +/** + * @author cedric dumoulin + * + */ +public class TypeLabelProvider extends LabelProvider { + + + @Override + public String getText(Object element) { + if(element instanceof Type) { + return ((Type)element).getName(); + } + + return super.getText(element); + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLibrary.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLibrary.java new file mode 100644 index 00000000000..ceedce02e5f --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLibrary.java @@ -0,0 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + +import java.util.ArrayList; +import java.util.List; + + +/** + * A library of predefined types + * + * @author cedric dumoulin + * + */ +public class TypeLibrary { + + final public Type INT = new Type("int"); + final public Type STRING = new Type("String"); + final public Type BOOLEAN = new Type("boolean"); + final public Type DOUBLE = new Type("double"); + + protected List<Type> types; + + + + + /** + * Constructor. + * + */ + public TypeLibrary() { + init(); + } + + + protected void init() { + types = new ArrayList<Type>(); + + types.add(INT); + types.add(STRING); + types.add(BOOLEAN); + types.add(DOUBLE); + + } + + /** + * @return the types + */ + public List<Type> getTypes() { + return types; + } + + + public Object getDefaultType() { + return STRING; + } + + + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeSelectorCellEditor.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeSelectorCellEditor.java new file mode 100644 index 00000000000..23cc5720d7e --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeSelectorCellEditor.java @@ -0,0 +1,198 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.jface.fieldassist.ContentProposalAdapter; +import org.eclipse.jface.fieldassist.IContentProposal; +import org.eclipse.jface.fieldassist.IContentProposalListener; +import org.eclipse.jface.fieldassist.IContentProposalProvider; +import org.eclipse.jface.fieldassist.TextContentAdapter; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist.TypeContentProposal; +import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist.TypeContentProposalProvider; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Text; + + +/** + * A {@link TextCellEditor} with content assist. + * + * @author cedric dumoulin + * + */ +public class TypeSelectorCellEditor extends TextCellEditor { + + /** + * Type catalog used to propose existing types. + */ + protected TypeLibrary typeCatalog; + + protected Type type; + + /** + * Label provider for type names + */ + protected ILabelProvider typeLabelProvider; + + /** + * Constructor. + * + */ + public TypeSelectorCellEditor( TypeLibrary typeLibrary, ILabelProvider typeLabelProvider) { + this.typeCatalog = typeLibrary; + this.typeLabelProvider = typeLabelProvider; + setDefaultType(); + // Try to install content assist + // Content assist is not installed if this method is called for the first time from the Constructor. + // This is because the typeCatalog is not set. + // So constructors need to also try to set the content assist, after typeCatalog is set. + installContentAssistantProvider(); + } + + /** + * Constructor. + * + * @param parent + * @param typeLibrary + */ + public TypeSelectorCellEditor(Composite parent, TypeLibrary typeLibrary, ILabelProvider typeLabelProvider) { + super(parent); + this.typeCatalog = typeLibrary; + this.typeLabelProvider = typeLabelProvider; + setDefaultType(); + // Try to install content assist + // Content assist is not installed if this method is called for the first time from the Constructor. + // This is because the typeCatalog is not set. + // So constructors need to also try to set the content assist, after typeCatalog is set. + installContentAssistantProvider(); + } + + /** + * Constructor. + * + * @param parent + * @param style + */ + public TypeSelectorCellEditor(Composite parent, int style, TypeLibrary typeLibrary, ILabelProvider typeLabelProvider) { + super(parent, style); + this.typeCatalog = typeLibrary; + this.typeLabelProvider = typeLabelProvider; + setDefaultType(); + // Try to install content assist + // Content assist is not installed if this method is called for the first time from the Constructor. + // This is because the typeCatalog is not set. + // So constructors need to also try to set the content assist, after typeCatalog is set. + installContentAssistantProvider(); + } + + /** + * Call parent to create the {@link Text} and install contentAssist + * @see org.eclipse.jface.viewers.TextCellEditor#createControl(org.eclipse.swt.widgets.Composite) + * + * @param parent + * @return + */ + protected Control createControl(Composite parent) { + + Control control = super.createControl(parent); + // Try to install content assist + // Content assist is not installed if this method is called for the first time from the Constructor. + // This is because the typeCatalog is not set. + // So constructors need to also try to set the content assist, after typeCatalog is set. + installContentAssistantProvider(); + + return control; + } + + /** + * Install the ContentAssistant if all required property are already set. + * + */ + protected void installContentAssistantProvider() { + + if( text==null || typeCatalog == null ) { + return; + } + + installContentAssistantProvider( new TypeContentProposalProvider(typeCatalog)); + } + + /** + * Install content assistant provider. + * + * @param control The control to which content assist is installed. + * + * @param contentProposalProvider The associated {@link ContentProposalAdapter}. + */ + protected void installContentAssistantProvider( IContentProposalProvider contentProposalProvider) { +// KeyStroke keyStroke = KeyStroke.getInstance("Ctrl+Space"); + KeyStroke keyStroke = null; + char[] autoActivationCharacters = null; + int autoActivationDelay = 500; + + ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(), contentProposalProvider, keyStroke, autoActivationCharacters); + adapter.setAutoActivationDelay(autoActivationDelay); + + // filter proposals as keys are pressed and proposals popup is present + adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE); + + // replace all text + adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE); + + // Listener called when a selection is made. + // Use the associated type to set the Type. + adapter.addContentProposalListener(new IContentProposalListener() { + + @Override + public void proposalAccepted(IContentProposal proposal) { + // set the corresponding type + if( proposal instanceof TypeContentProposal ) { + TypeContentProposal typeProposal = (TypeContentProposal)proposal; + setType(typeProposal.getType()); + } + + } + }); + + } + + public Type getType() { + return type; + } + + public void setType( Type type) { + setValue(type); + } + + public void setDefaultType() { + setValue(typeCatalog.getDefaultType()); + } + + @Override + protected void doSetValue(Object value) { + Assert.isTrue(value != null && (value instanceof Type)); + type = (Type)value; + super.doSetValue(typeLabelProvider.getText(type)); + } + + @Override + protected Object doGetValue() { + return type; + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposal.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposal.java new file mode 100644 index 00000000000..3554373e7cc --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposal.java @@ -0,0 +1,69 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist; + +import org.eclipse.jface.fieldassist.IContentProposal; +import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.Type; + + +/** + * Field assist {@link IContentProposal} . + * This implementation is used to render one proposal of a {@link Stereotype} as a short name: + * shortName (profil) + * + * @author cedric dumoulin + * + */ +public class TypeContentProposal extends TypeContentProposalBase implements IContentProposal, Comparable<IContentProposal> { + + /** + * Constructor. + * + * @param stereotype + */ + public TypeContentProposal(Type type) { + super( type ); + } + + /** + * @see org.eclipse.jface.fieldassist.IContentProposal#getContent() + * + * @return + */ + public String getContent() { + return type.getName() ; + } + + /** + * @see org.eclipse.jface.fieldassist.IContentProposal#getCursorPosition() + * + * @return + */ + public int getCursorPosition() { + return getContent().length(); + } + + /** + * @see org.eclipse.jface.fieldassist.IContentProposal#getLabel() + * + * @return + */ + public String getLabel() { + + return type.getName(); + } + + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalBase.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalBase.java new file mode 100644 index 00000000000..c8374dffd79 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalBase.java @@ -0,0 +1,70 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist; + +import java.util.List; + +import org.eclipse.jface.fieldassist.IContentProposal; +import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.Type; + + +/** + * Field assist {@link IContentProposal} . + * Base class for TypeContentProposal. + * + * + * @author cedric dumoulin + * + */ +public abstract class TypeContentProposalBase implements IContentProposal, Comparable<IContentProposal> { + + /** + * The type that is render. + */ + protected Type type; + + + /** + * Constructor. + * + * @param stereotype + */ + public TypeContentProposalBase(Type type) { + this.type = type; + } + + /** + * @see org.eclipse.jface.fieldassist.IContentProposal#getDescription() + * + * @return + */ + public String getDescription() { + + return type.getName(); + } + + public int compareTo(IContentProposal o) { + return this.getLabel().compareTo(o.getLabel()); + } + + + /** + * @return the type + */ + public Type getType() { + return type; + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalProvider.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalProvider.java new file mode 100644 index 00000000000..a808cf7c117 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalProvider.java @@ -0,0 +1,77 @@ +package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.jface.fieldassist.IContentProposal; +import org.eclipse.jface.fieldassist.IContentProposalProvider; +import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.Type; +import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.TypeLibrary; + +/** + * A {@link IContentProposalProvider} providing {@link Type} names. + * + * @author cedric dumoulin + * + */ +public class TypeContentProposalProvider implements IContentProposalProvider { + + /** + * The types that will be proposed. + */ + private TypeLibrary typeCatalog; + + /** + * Constructor. + * + * @param stereotypes + */ + public TypeContentProposalProvider(TypeLibrary typeCatalog) { + this.typeCatalog = typeCatalog; + } + + + /** + * + * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int) + * + * @param contents + * @param position + * @return + */ + public IContentProposal[] getProposals(String contents, int position) { + + List<TypeContentProposalBase> shortProposals = new ArrayList<TypeContentProposalBase>(); + + + List<Type> types = typeCatalog.getTypes(); + + for( Type type : types) { + final String simpleName = type.getName(); + + if(match(simpleName, contents, position)) { + shortProposals.add(new TypeContentProposal(type)); + } + } + + // Now concat both list + Collections.sort(shortProposals); + + return shortProposals.toArray(new IContentProposal[shortProposals.size()]); + } + + + /** + * Return true if the actual proposal math the provided name. False otherwise. + * + * @param name The name to check + * @param proposal The actual proposal of user + * @param position The cursor position in the user proposal. + * @return + */ + private boolean match(final String name, String proposal, int position) { + return position < name.length() && proposal.substring(0, position).equalsIgnoreCase(name.substring(0, position)); + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/utils/UMLModelCreatorTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/utils/UMLModelCreatorTest.java new file mode 100644 index 00000000000..4cc66a5b11b --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/utils/UMLModelCreatorTest.java @@ -0,0 +1,228 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.tests.utils; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + +import java.util.Iterator; + +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.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.DataType; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.resource.UMLResource; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterators; + + +/** + * @author cedric dumoulin + * + */ +public class UMLModelCreatorTest { + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * + * @return + */ + protected Resource createResource(String uriName) { + ResourceSet resourceSet = new ResourceSetImpl(); + + // True for local test, false for plugin test + if(true) { + // Register the default resource factory -- only needed for stand-alone! + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( + Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( + UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE ); + + } + + URI uri = URI.createURI(uriName); + Resource resource = resourceSet.createResource(uri); + + return resource; + } + + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#UMLModelCreator(java.lang.String, java.lang.String)}. + */ + @Test + public void testUMLModelCreatorStringString() { + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + + assertNotNull("Object created", creator); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#UMLModelCreator(org.eclipse.emf.ecore.resource.Resource)}. + */ + @Test + public void testUMLModelCreatorResourceFailing() { + Resource resource = createResource("temp.uml"); + + try { + UMLModelCreator creator = new UMLModelCreator(resource); + fail("Exception must be thrown"); + } catch (IllegalArgumentException e) { + // ok + } + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#UMLModelCreator(org.eclipse.emf.ecore.resource.Resource)}. + */ + @Test + public void testUMLModelCreatorResource() { + Resource resource = createResource("temp.uml"); + + Model rootModel = UMLFactory.eINSTANCE.createModel(); + rootModel.setName("model"); + resource.getContents().add(rootModel); + + UMLModelCreator creator = new UMLModelCreator(resource); + + assertNotNull("Object created", creator); + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#cd(org.eclipse.uml2.uml.Package)}. + */ + @Test + public void testCd() { + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + + creator.createPackage("p1", false); + Package p2 = creator.createPackage("p2", false); + creator.createPackage("p3", false); + + creator.cd(p2); + + assertSame("current package changed", creator.getCurrentDir(), p2); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#createClass(java.lang.String)}. + */ + @Test + public void testCreateClass() { + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + + Class c = creator.createClass("c1"); + + assertNotNull("Object created", c); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#createDatatype(java.lang.String)}. + */ + @Test + public void testCreateDatatype() { + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + + DataType c = creator.createDatatype("c1"); + + assertNotNull("Object created", c); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#createPackage(java.lang.String)}. + */ + @Test + public void testCreatePackage() { + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + + Package c = creator.createPackage("c1"); + + assertNotNull("Object created", c); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator#createModel(java.lang.String)}. + */ + @Test + public void testCreateModel() { + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + + Model c = creator.createModel("c1"); + + assertNotNull("Object created", c); + } + + /** + * + */ + @Test + public void testCreation() { + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + // Create model + Package p1 = creator.createPackage("p1"); + creator.createDatatype("dt1"); + creator.createDatatype("dt2"); + creator.createClass("C1"); + creator.cdToRoot(); + Package p2 = creator.createPackage("p2"); + creator.createDatatype("dt21"); + creator.createDatatype("dt12"); + creator.createClass("C21"); + + int expectedDatatypeCount = 4; + int expectedElementeCount = 9; + + assertSame("Expected count", expectedElementeCount, Iterators.size( creator.getResource().getAllContents() )); + + Iterator<EObject> iter = creator.getResource().getAllContents(); + Iterator<DataType> datatypesIter = Iterators.filter(iter, DataType.class); + assertSame("Expected count", expectedDatatypeCount, Iterators.size(datatypesIter)); + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/CompoundTypeProviderTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/CompoundTypeProviderTest.java new file mode 100644 index 00000000000..54813b06ae9 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/CompoundTypeProviderTest.java @@ -0,0 +1,130 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.ui.model; + +import static org.junit.Assert.*; + +import org.eclipse.core.commands.ITypedParameter; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + + +/** + * @author cedric dumoulin + * + */ +public class CompoundTypeProviderTest { + + protected Type type1; + protected Type type2; + protected Type type3; + protected int typeCount; + + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + type1 = UMLFactory.eINSTANCE.createPrimitiveType(); + type1.setName("int"); + type2 = UMLFactory.eINSTANCE.createPrimitiveType(); + type2.setName("boolean"); + type3 = UMLFactory.eINSTANCE.createPrimitiveType(); + type3.setName("double"); + + typeCount = 2; + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.CompoundTypeProvider#CompoundTypeProvider(org.eclipse.papyrus.uml.profile.drafter.ui.model.ITypeCatalog[])}. + */ + @Test + public void testCompoundTypeProvider() { + ITypeCatalog provider1 = new TypeProvider(type1); + ITypeCatalog provider2 = new TypeProvider(type2); + + CompoundTypeProvider provider = new CompoundTypeProvider(provider1, provider2); + + assertNotNull("object created", provider); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.CompoundTypeProvider#getTypes()}. + */ + @Test + public void testGetTypes() { + ITypeCatalog provider1 = new TypeProvider(type1); + ITypeCatalog provider2 = new TypeProvider(type2); + int typeCount = 2; + + CompoundTypeProvider provider = new CompoundTypeProvider(provider1, provider2); + + assertNotNull("list created", provider.getTypes()); + assertEquals("All types found", typeCount, provider.getTypes().size()); + + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.CompoundTypeProvider#iterator()}. + */ + @Test + public void testIterator() { + ITypeCatalog provider1 = new TypeProvider(type1); + ITypeCatalog provider2 = new TypeProvider(type2); + + CompoundTypeProvider provider = new CompoundTypeProvider(provider1, provider2); + + assertNotNull("iterator found", provider.iterator()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.CompoundTypeProvider#addITypeProvider(org.eclipse.papyrus.uml.profile.drafter.ui.model.ITypeCatalog)}. + */ + @Test + public void testAddITypeProvider() { + ITypeCatalog provider1 = new TypeProvider(type1); + ITypeCatalog provider2 = new TypeProvider(type2); + int typeCount = 2; + + CompoundTypeProvider provider = new CompoundTypeProvider(provider1); + + provider.addITypeProvider(provider2); + + + assertNotNull("list created", provider.getTypes()); + assertEquals("All types found", typeCount, provider.getTypes().size()); + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/DummySimpleModelVisitor.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/DummySimpleModelVisitor.java new file mode 100644 index 00000000000..77edf7f5c5a --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/DummySimpleModelVisitor.java @@ -0,0 +1,55 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.ui.model; + +import org.eclipse.papyrus.uml.profile.drafter.tests.TracesRecorder; + + +/** + * @author dumoulin + * + */ +public class DummySimpleModelVisitor extends SimpleModelVisitor { + + TracesRecorder<String, Object> traces = new TracesRecorder<String, Object>(); + + public DummySimpleModelVisitor() { + // TODO Auto-generated constructor stub + } + + @Override + public void doVisit(StereoptypeModel model) { + super.doVisit(model); + traces.records("doVisit", "StereoptypeModel", model); + } + + @Override + public void doVisit( PropertyModel model) { + super.doVisit(model); + traces.records("doVisit", "PropertyModel", model); + } + + @Override + public void doVisit( ExtendedStereotypeModel model) { + super.doVisit(model); + traces.records("doVisit", "ExtendedStereotypeModel", model); + } + + @Override + public void doVisit( MetaclassModel model) { + super.doVisit(model); + traces.records("doVisit", "MetaclassesModel", model); + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/SimpleModelVisitorTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/SimpleModelVisitorTest.java new file mode 100644 index 00000000000..19cde902663 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/SimpleModelVisitorTest.java @@ -0,0 +1,149 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.ui.model; + +import static org.junit.Assert.*; + +import org.eclipse.core.databinding.observable.Realm; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.papyrus.uml.profile.drafter.tests.TracesRecorder; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * @author cedric dumoulin + * + */ +public class SimpleModelVisitorTest { + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitor#visit(org.eclipse.papyrus.uml.profile.drafter.ui.model.StereoptypeModel)}. + */ + @Test + public void testSimpleModelVisitor() { + + SimpleModelVisitor visitor = new DummySimpleModelVisitor(); + + assertNotNull("object created", visitor); + } + + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitor#visit(org.eclipse.papyrus.uml.profile.drafter.ui.model.StereoptypeModel)}. + * @Ignore Disabled because the {@link WritableList} require a valid {@link Realm} to work. + * + */ + @Test + @Ignore + public void testVisitStereoptypeModel() { + // Create a Model + String propName1 = "propName1"; + String propName2 = "propName2"; + String propName3 = "propName3"; + + StereoptypeModel st = new StereoptypeModel(); + PropertyModel prop1 = st.createNewPropertyModel(propName1); + PropertyModel prop2 = st.createNewPropertyModel(propName2); + ExtendedStereotypeModel exSt1 = st.createExtendedStereotypeModel("exSt1"); + PropertyModel prop3 = st.createNewPropertyModel(propName3); + MetaclassModel mc1 = st.createMetaclassModel("mc1"); + + // tests + // Check visit order. + DummySimpleModelVisitor visitor = new DummySimpleModelVisitor(); + st.accept(visitor); + + TracesRecorder<String, Object> recorder = visitor.traces; + int i=0; + assertEquals("right count", 6, recorder.traces.size()); + assertSame("visited member", st, recorder.get(i++).obj2); + assertSame("visited member", prop1, recorder.get(i++).obj2); + assertSame("visited member", prop2, recorder.get(i++).obj2); + assertSame("visited member", prop3, recorder.get(i++).obj2); + assertSame("visited member", mc1, recorder.get(i++).obj2); + assertSame("visited member", exSt1, recorder.get(i++).obj2); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitor#visit(org.eclipse.papyrus.uml.profile.drafter.ui.model.PropertyModel)}. + */ + @Test + @Ignore + public void testVisitPropertyModel() { + fail("Not yet implemented"); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitor#visit(org.eclipse.papyrus.uml.profile.drafter.ui.model.MetaclassModel)}. + */ + @Test + @Ignore + public void testVisitMetaclassesModel() { + fail("Not yet implemented"); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitor#doVisit(org.eclipse.papyrus.uml.profile.drafter.ui.model.StereoptypeModel)}. + */ + @Test + @Ignore + public void testDoVisitStereoptypeModel() { + fail("Not yet implemented"); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitor#doVisit(org.eclipse.papyrus.uml.profile.drafter.ui.model.PropertyModel)}. + */ + @Test + @Ignore + public void testDoVisitPropertyModel() { + fail("Not yet implemented"); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.SimpleModelVisitor#doVisit(org.eclipse.papyrus.uml.profile.drafter.ui.model.MetaclassModel)}. + */ + @Test + @Ignore + public void testDoVisitMetaclassesModel() { + fail("Not yet implemented"); + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/StereotypeURLTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/StereotypeURLTest.java new file mode 100644 index 00000000000..6a4bbdcf52b --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/StereotypeURLTest.java @@ -0,0 +1,349 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.ui.model; + +import static org.junit.Assert.*; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * @author cedric dumoulin + * + */ +public class StereotypeURLTest { + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#StereotypeURL()}. + */ + @Test + public void testStereotypeURL() { + + StereotypeURL url = new StereotypeURL(); + assertNotNull("url created", url); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#StereotypeURL(String)}. + */ + @Test + public void testStereotypeURLString() { + + String stereotypeName = "Town"; + StereotypeURL url = new StereotypeURL(stereotypeName); + assertNotNull("url created", url); + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", stereotypeName, url.getStereotypeName()); + assertEquals("qualifiedName set", stereotypeName, url.getQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#StereotypeURL(String)}. + */ + @Test + public void testStereotypeURLStringString() { + + String profileName = "profile"; + String stereotypeName = "Town"; + StereotypeURL url = new StereotypeURL(profileName, stereotypeName); + assertNotNull("url created", url); + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + + assertEquals("stereotype set", stereotypeName, url.getStereotypeName()); + assertEquals("qualifiedName set", profileName + "::" + stereotypeName, url.getQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#getQualifiedName()}. + */ + @Test + public void testGetQualifiedName() { + String qualifiedName = "Town"; + StereotypeURL url = new StereotypeURL(); + url.setQualifiedName(qualifiedName); + + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", qualifiedName, url.getStereotypeName()); + assertEquals("qualifiedName set", qualifiedName, url.getQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#setQualifiedName(java.lang.String)}. + */ + @Test + public void testSetQualifiedNameComplex() { + String profileName = "profile"; + String stereotypeName = "Town"; + String qualifiedName = profileName + "::" + stereotypeName; + StereotypeURL url = new StereotypeURL(); + + url.setQualifiedName(qualifiedName); + + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", stereotypeName, url.getStereotypeName()); + assertEquals("paths", profileName, url.getProfileName()); + assertEquals("qualifiedName set", qualifiedName, url.getQualifiedName()); + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#setQualifiedName(java.lang.String)}. + */ + @Test + public void testSetQualifiedNameSimple() { + String qualifiedName = "Town"; + StereotypeURL url = new StereotypeURL(); + url.setQualifiedName(qualifiedName); + + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", qualifiedName, url.getStereotypeName()); + assertEquals("qualifiedName set", qualifiedName, url.getQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#clear()}. + */ + @Test + public void testClear() { + String profileName = "profile"; + String stereotypeName = "Town"; + StereotypeURL url = new StereotypeURL(profileName, stereotypeName); + + url.clear(); + + assertEquals("qualifiedName reset", "", url.getQualifiedName()); + assertEquals("ProfileName reset", "", url.getProfileName()); + assertEquals("StereotypeName reset", "", url.getStereotypeName()); + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#getStereotypeName()}. + */ + @Test + public void testGetStereotypeName() { + String stereotypeName = "Town"; + StereotypeURL url = new StereotypeURL(); + url.setStereotypeName(stereotypeName); + + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", stereotypeName, url.getStereotypeName()); + assertEquals("qualifiedName set", stereotypeName, url.getQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#setStereotypeName(java.lang.String)}. + */ + @Test + public void testSetStereotypeName() { + String stereotypeName = "Town"; + StereotypeURL url = new StereotypeURL(); + url.setStereotypeName(stereotypeName); + + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", stereotypeName, url.getStereotypeName()); + assertEquals("qualifiedName set", stereotypeName, url.getQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#getProfileName()}. + */ + @Test + public void testGetProfileName() { + String profile1 = "profile1"; + String profile2 = "profile2"; + String profile3 = "profile3"; + String profileNames = profile1 + "::" + profile2 + "::"+ profile3; + String stereotypeName = "Town"; + String qualifiedName = profileNames + "::" + stereotypeName; + StereotypeURL url = new StereotypeURL(); + + url.setQualifiedName(qualifiedName); + + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", stereotypeName, url.getStereotypeName()); + assertEquals("qualifiedName set", qualifiedName, url.getQualifiedName()); + assertEquals("paths", profileNames, url.getProfileName() ); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#setProfileName(String)}. + */ + @Test + public void testSetProfileName() { + String oldProfileName = "oldProfileName"; + String newProfileName = "newProfileName"; + String stereotypeName = "Town"; + String qualifiedName = oldProfileName + "::" + stereotypeName; + String expectedQualifiedName = newProfileName + "::" + stereotypeName; + StereotypeURL url = new StereotypeURL(); + + url.setQualifiedName(qualifiedName); + url.setProfileName(newProfileName); + + assertNotNull("stereotype set", url.getStereotypeName()); + assertNotNull("qualifiedName set", url.getQualifiedName()); + assertEquals("stereotype set", stereotypeName, url.getStereotypeName()); + assertEquals("paths", newProfileName, url.getProfileName() ); + assertEquals("qualifiedName set", expectedQualifiedName, url.getQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#computeQualifiedName()}. + */ + @Test + public void testComputeQualifiedName() { + String profileName = "profile"; + String stereotypeName = "Town"; + String qualifiedName = profileName + "::" + stereotypeName; + StereotypeURL url = new StereotypeURL(); + +// url.setQualifiedName(qualifiedName); + url.setProfileName(profileName); + url.setStereotypeName(stereotypeName); + + assertEquals("qualifiedName computed correctly", qualifiedName, url.computeQualifiedName()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#toString()}. + */ + @Test + public void testToString() { + String profileName = "profile"; + String stereotypeName = "Town"; + String qualifiedName = profileName + "::" + stereotypeName; + StereotypeURL url = new StereotypeURL(); + + url.setQualifiedName(qualifiedName); + + assertEquals("stereotype set", qualifiedName, url.toString()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#addPropertyChangeListener(java.beans.PropertyChangeListener)}. + */ + @Test + public void testAddPropertyChangeListenerPropertyChangeListener() { + + PropertyChangeListener listener = new DummyPropertyChangeListener(); + + StereotypeURL url = new StereotypeURL(); + + url.addPropertyChangeListener(listener); + + assertEquals("listener added to list", 1, url.getChangeSupport().getPropertyChangeListeners().length); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#removePropertyChangeListener(java.beans.PropertyChangeListener)}. + */ + @Test + public void testRemovePropertyChangeListenerPropertyChangeListener() { + PropertyChangeListener listener = new DummyPropertyChangeListener(); + + StereotypeURL url = new StereotypeURL(); + + url.addPropertyChangeListener(listener); + url.removePropertyChangeListener(listener); + + assertEquals("listener added to list", 0, url.getChangeSupport().getPropertyChangeListeners().length); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)}. + */ + @Test + public void testAddPropertyChangeListenerStringPropertyChangeListener() { + PropertyChangeListener listener = new DummyPropertyChangeListener(); + + StereotypeURL url = new StereotypeURL(); + + url.addPropertyChangeListener(StereotypeURL.QUALIFIED_NAME, listener); + + assertEquals("listener added to list", 1, url.getChangeSupport().getPropertyChangeListeners().length); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.StereotypeURL#removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)}. + */ + @Test + public void testRemovePropertyChangeListenerStringPropertyChangeListener() { + PropertyChangeListener listener = new DummyPropertyChangeListener(); + + StereotypeURL url = new StereotypeURL(); + + url.addPropertyChangeListener(StereotypeURL.QUALIFIED_NAME, listener); + url.removePropertyChangeListener(StereotypeURL.QUALIFIED_NAME, listener); + + assertEquals("listener added to list", 0, url.getChangeSupport().getPropertyChangeListeners().length); + } + + /** + * Fake listener for tests. + * + */ + public class DummyPropertyChangeListener implements PropertyChangeListener { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + + } + + } +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/TypeProviderTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/TypeProviderTest.java new file mode 100644 index 00000000000..ac232d5897e --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/TypeProviderTest.java @@ -0,0 +1,125 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.ui.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.uml.profile.drafter.tests.utils.UMLModelCreator; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.Iterators; + + +/** + * @author cedric dumoulin + * + */ +public class TypeProviderTest { + + protected UMLModelCreator creator; + int expectedDatatypeCount; + + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + createUmlModel(); + + } + + /** + * + */ + private void createUmlModel() { + creator = new UMLModelCreator("temp.uml", "model"); + // Create model + creator.createPackage("p1"); + creator.createDatatype("dt1"); + creator.createDatatype("dt2"); + creator.createClass("C1"); + creator.cdToRoot(); + creator.createPackage("p2"); + creator.createDatatype("dt21"); + creator.createDatatype("dt12"); + creator.createClass("C21"); + + expectedDatatypeCount = 4; + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.ResourceTypeProvider#TypeProvider(org.eclipse.emf.ecore.resource.Resource, org.eclipse.emf.ecore.EClass)}. + */ + @Test + public void testTypeProvider() { + + UMLModelCreator creator = new UMLModelCreator("temp.uml", "model"); + + EClass requestedType = UMLPackage.eINSTANCE.getClass_(); + ResourceTypeProvider typeProvider = new ResourceTypeProvider(creator.getResource(), requestedType); + + assertNotNull("Object created", typeProvider); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.ResourceTypeProvider#getTypes()}. + */ + @Test + public void testGetTypes() { + + EClass requestedType = UMLPackage.eINSTANCE.getDataType(); + ResourceTypeProvider typeProvider = new ResourceTypeProvider(creator.getResource(), requestedType); + + List<Type> types = typeProvider.getTypes(); + + assertEquals("Types found", expectedDatatypeCount, types.size()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.ResourceTypeProvider#iterator()}. + */ + @Test + public void testIterator() { + EClass requestedType = UMLPackage.eINSTANCE.getDataType(); + ResourceTypeProvider typeProvider = new ResourceTypeProvider(creator.getResource(), requestedType); + + assertEquals("Types found", expectedDatatypeCount, Iterators.size(typeProvider.iterator())); + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/TypeProviderTest2.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/TypeProviderTest2.java new file mode 100644 index 00000000000..19d2da0f99a --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/ui/model/TypeProviderTest2.java @@ -0,0 +1,143 @@ +/***************************************************************************** + * Copyright (c) 2014 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.profile.drafter.ui.model; + +import static org.junit.Assert.*; + +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + + +/** + * @author cedric dumoulin + * + */ +public class TypeProviderTest2 { + + protected Type type1; + protected Type type2; + protected int typeCount; + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + type1 = UMLFactory.eINSTANCE.createPrimitiveType(); + type1.setName("int"); + type2 = UMLFactory.eINSTANCE.createPrimitiveType(); + type2.setName("boolean"); + + typeCount = 2; + + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + type1 = null; + type2 = null; + typeCount = 0; + + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProvider#TypeCatalog()}. + */ + @Test + public void testTypeProvider() { + TypeProvider provider = new TypeProvider(); + + assertNotNull("object created", provider); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProvider#TypeCatalog(org.eclipse.uml2.uml.Type[])}. + */ + @Test + public void testTypeProviderTypeArray() { + + + TypeProvider provider = new TypeProvider(type1, type2); + + assertNotNull("object created", provider); + assertNotNull("list created", provider.getTypes()); + assertEquals("all types created", typeCount, provider.getTypes().size()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProvider#getTypes()}. + */ + @Test + public void testGetTypes() { + TypeProvider provider = new TypeProvider(); + + assertNotNull("list created", provider.getTypes()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProvider#iterator()}. + */ + @Test + public void testIterator() { + TypeProvider provider = new TypeProvider(); + + provider.addType(type1); + provider.addType(type2); + + assertNotNull("iterator found", provider.iterator()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProvider#addType(org.eclipse.uml2.uml.Type)}. + */ + @Test + public void testAddType() { + TypeProvider provider = new TypeProvider(); + + provider.addType(type1); + provider.addType(type2); + + assertNotNull("list created", provider.getTypes()); + assertEquals("all types created", typeCount, provider.getTypes().size()); + } + + /** + * Test method for {@link org.eclipse.papyrus.uml.profile.drafter.ui.model.TypeProvider#addType(org.eclipse.uml2.uml.Type)}. + */ + @Test + public void testAddTypeFromConstructor() { + TypeProvider provider = new TypeProvider(type1); + + provider.addType(type2); + + assertNotNull("list created", provider.getTypes()); + assertEquals("all types created", typeCount, provider.getTypes().size()); + } + +} diff --git a/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/utils/UMLPrimitiveTypesModelTest.java b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/utils/UMLPrimitiveTypesModelTest.java new file mode 100644 index 00000000000..a3a692d2612 --- /dev/null +++ b/tests/junit/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/utils/UMLPrimitiveTypesModelTest.java @@ -0,0 +1,90 @@ +package org.eclipse.papyrus.uml.profile.drafter.utils; + +import static org.junit.Assert.*; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.XMIResource; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.papyrus.uml.profile.drafter.exceptions.NotFoundException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +/** + * + * @author cedric dumoulin + * + */ +public class UMLPrimitiveTypesModelTest { + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + /** + * Creates and returns a temporary resource set. The resource set can be used to load libraries + * without polluting the current ModelSet. + * + * It is configured with XMI Load options, to allow safe loading of resources + * + * @return + * A temporary resource set + * + */ + public static ResourceSet createTemporaryResourceSet() { + ResourceSet tmpResourceSet = new ResourceSetImpl(); + + tmpResourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true); + tmpResourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true); + tmpResourceSet.getLoadOptions().put(XMIResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE); + tmpResourceSet.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE); + + return tmpResourceSet; + } + + /** + * + * @throws NotFoundException + */ + @Test + public void testUMLPrimitiveTypesModel() throws NotFoundException { + + ResourceSet resourceSet = createTemporaryResourceSet(); + + UMLPrimitiveTypesModel model = new UMLPrimitiveTypesModel(resourceSet); + + assertNotNull("object created", model); + assertNotNull("resource", model.getLibraryResource()); + assertNotNull("boolean", model.UMLPrimitiveTypes_BOOLEAN); + assertNotNull("integer", model.UMLPrimitiveTypes_INTEGER); + assertNotNull("real", model.UMLPrimitiveTypes_REAL); + assertNotNull("string", model.UMLPrimitiveTypes_STRING); + assertNotNull("unlimited_natural", model.UMLPrimitiveTypes_UNLIMITED_NATURAL); + } + + /** + * + * @throws NotFoundException + */ + @Test + public void testGetLibraryPackage() throws NotFoundException { + + ResourceSet resourceSet = createTemporaryResourceSet(); + + UMLPrimitiveTypesModel model = new UMLPrimitiveTypesModel(resourceSet); + + assertNotNull("package", model.getLibraryPackage()); + } + + +} |