Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-08-24 12:22:05 -0400
committervlorenzo2012-08-24 12:22:05 -0400
commitc98ff0e6a92ae28ec7372c2bef045bf31e12fcf7 (patch)
tree7e4563956d886eeb4320168417ad473e60b7d65c
parent16f26711f56b203427213b5d227acd3304412e77 (diff)
downloadorg.eclipse.papyrus-c98ff0e6a92ae28ec7372c2bef045bf31e12fcf7.tar.gz
org.eclipse.papyrus-c98ff0e6a92ae28ec7372c2bef045bf31e12fcf7.tar.xz
org.eclipse.papyrus-c98ff0e6a92ae28ec7372c2bef045bf31e12fcf7.zip
Share the tests for the generic table
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.classpath7
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.project28
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/META-INF/MANIFEST.MF23
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/build.properties4
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/org.eclipse.papyrus.uml.table.efacet.generic.tests.launch41
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.di17
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.notation37
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.uml7
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/Activator.java50
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/AllTests.java25
-rw-r--r--sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/synchronization/features/DerivedFeatureTests.java211
12 files changed, 457 insertions, 0 deletions
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.classpath b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.classpath
@@ -0,0 +1,7 @@
+<?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/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.project b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.project
new file mode 100644
index 00000000000..631f711272d
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.table.efacet.generic.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/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.settings/org.eclipse.jdt.core.prefs b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.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.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/META-INF/MANIFEST.MF b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..0829c9f0fb0
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tests UML Generic Table (Incubation)
+Bundle-SymbolicName: org.eclipse.papyrus.uml.table.efacet.generic.tests
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.uml.table.efacet.generic.tests.Activator
+Bundle-Vendor: Eclipse Modeling Project
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.junit;bundle-version="4.10.0",
+ org.eclipse.papyrus.uml.table.efacet.generic;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.table.efacet.common;bundle-version="0.9.0",
+ org.eclipse.papyrus.junit.utils;bundle-version="0.9.0",
+ org.eclipse.papyrus.views.modelexplorer,
+ org.eclipse.core.resources,
+ org.eclipse.uml2.uml;bundle-version="4.0.0",
+ org.eclipse.ui.navigator;bundle-version="3.5.200",
+ org.eclipse.papyrus.infra.table.efacet.metamodel;bundle-version="0.9.0",
+ org.eclipse.emf.facet.widgets.table.ui,
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/build.properties b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/build.properties
new file mode 100644
index 00000000000..41eb6ade2b4
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/org.eclipse.papyrus.uml.table.efacet.generic.tests.launch b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/org.eclipse.papyrus.uml.table.efacet.generic.tests.launch
new file mode 100644
index 00000000000..d7d8c26371b
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/org.eclipse.papyrus.uml.table.efacet.generic.tests.launch
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="clearws" value="true"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="default" value="true"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/AllTests.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.papyrus.uml.table.efacet.generic.tests.AllTests"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.papyrus.uml.table.efacet.generic.tests"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms60m -Xmx1024m -DsuppressRawWhenUnchecked=true -XX:MaxPermSize=256M"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.platform.ide"/>
+<booleanAttribute key="run_in_ui_thread" value="true"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useProduct" value="true"/>
+</launchConfiguration>
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.di b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.di
new file mode 100644
index 00000000000..61c16241819
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.di
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="ASCII"?>
+<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
+ <pageList>
+ <availablePage>
+ <emfPageIdentifier href="model.notation#_9tRbkOEkEeGGo5AIoeD6vw"/>
+ </availablePage>
+ </pageList>
+ <sashModel currentSelection="//@sashModel/@windows.0/@children.0">
+ <windows>
+ <children xsi:type="di:TabFolder">
+ <children>
+ <emfPageIdentifier href="model.notation#_9tRbkOEkEeGGo5AIoeD6vw"/>
+ </children>
+ </children>
+ </windows>
+ </sashModel>
+</di:SashWindowsMngr>
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.notation b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.notation
new file mode 100644
index 00000000000..609aeb8e987
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.notation
@@ -0,0 +1,37 @@
+<?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:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_9tRbkOEkEeGGo5AIoeD6vw" type="PapyrusUMLClassDiagram" name="NewDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="__O3xMOEkEeGGo5AIoeD6vw" type="2008" fontName="Segoe UI" lineColor="0">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__O-e4OEkEeGGo5AIoeD6vw" source="ShadowFigure">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__O-e4eEkEeGGo5AIoeD6vw" key="ShadowFigure_Value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__O-e4uEkEeGGo5AIoeD6vw" source="displayNameLabelIcon">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__O-e4-EkEeGGo5AIoeD6vw" key="displayNameLabelIcon_value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__O_F8OEkEeGGo5AIoeD6vw" source="QualifiedName">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__O_F8eEkEeGGo5AIoeD6vw" key="QualifiedNameDepth" value="1000"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="__PA7IOEkEeGGo5AIoeD6vw" type="5029"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__PCwUOEkEeGGo5AIoeD6vw" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__PCwUeEkEeGGo5AIoeD6vw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__PCwUuEkEeGGo5AIoeD6vw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__PCwU-EkEeGGo5AIoeD6vw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__PCwVOEkEeGGo5AIoeD6vw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__PCwVeEkEeGGo5AIoeD6vw" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__PCwVuEkEeGGo5AIoeD6vw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__PCwV-EkEeGGo5AIoeD6vw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__PCwWOEkEeGGo5AIoeD6vw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__PCwWeEkEeGGo5AIoeD6vw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="__PCwWuEkEeGGo5AIoeD6vw" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="__PCwW-EkEeGGo5AIoeD6vw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="__PCwXOEkEeGGo5AIoeD6vw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="__PCwXeEkEeGGo5AIoeD6vw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__PCwXuEkEeGGo5AIoeD6vw"/>
+ </children>
+ <element xmi:type="uml:Class" href="model.uml#__OR7UOEkEeGGo5AIoeD6vw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__O3xMeEkEeGGo5AIoeD6vw" x="332" y="203"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_9tSCoOEkEeGGo5AIoeD6vw"/>
+ <element xmi:type="uml:Model" href="model.uml#_9ssMwOEkEeGGo5AIoeD6vw"/>
+</notation:Diagram>
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.uml b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.uml
new file mode 100644
index 00000000000..6ca721ad327
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/resources/model.uml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_9ssMwOEkEeGGo5AIoeD6vw" name="Model">
+ <packageImport xmi:id="_9ssMweEkEeGGo5AIoeD6vw">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+ <packagedElement xmi:type="uml:Class" xmi:id="__OR7UOEkEeGGo5AIoeD6vw" name="Class1"/>
+</uml:Model>
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/Activator.java b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/Activator.java
new file mode 100644
index 00000000000..1c06e378b0b
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.papyrus.uml.table.efacet.generic.tests;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.table.efacet.generic.tests"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/AllTests.java b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/AllTests.java
new file mode 100644
index 00000000000..8dc4ecd6d5d
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/AllTests.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.table.efacet.generic.tests;
+
+import org.eclipse.papyrus.uml.table.efacet.generic.tests.synchronization.features.DerivedFeatureTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({ DerivedFeatureTests.class })
+public class AllTests {
+ // JUnit 4 test suite
+}
diff --git a/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/synchronization/features/DerivedFeatureTests.java b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/synchronization/features/DerivedFeatureTests.java
new file mode 100644
index 00000000000..54c28dc8d5d
--- /dev/null
+++ b/sandbox/org.eclipse.papyrus.uml.table.efacet.generic.tests/src/org/eclipse/papyrus/uml/table/efacet/generic/tests/synchronization/features/DerivedFeatureTests.java
@@ -0,0 +1,211 @@
+package org.eclipse.papyrus.uml.table.efacet.generic.tests.synchronization.features;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Row;
+import org.eclipse.emf.facet.widgets.table.ui.internal.exported.TableWidgetUtils;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel;
+import org.eclipse.papyrus.infra.table.efacet.metamodel.papyrustable.FillingMode;
+import org.eclipse.papyrus.infra.table.efacet.metamodel.papyrustable.PapyrusTable;
+import org.eclipse.papyrus.junit.utils.EditorUtils;
+import org.eclipse.papyrus.junit.utils.GenericUtils;
+import org.eclipse.papyrus.junit.utils.HandlerUtils;
+import org.eclipse.papyrus.junit.utils.ModelExplorerUtils;
+import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils;
+import org.eclipse.papyrus.junit.utils.ProjectUtils;
+import org.eclipse.papyrus.uml.table.efacet.generic.tests.Activator;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+public class DerivedFeatureTests {
+
+ private static final String CREATE_GENERIC_UML_TABLE = "org.eclipse.papyrus.uml.generic.table.command.withoutdialog"; //$NON-NLS-1$
+
+ private static final String MODEL = "model"; //$NON-NLS-1$
+
+ private static ModelExplorerView modelExplorerView;
+
+ private static IProject project;
+
+ private static CoreMultiDiagramEditor papyrusEditor;
+
+ private static Class class1;
+
+ @BeforeClass
+ public static void init() throws CoreException, IOException {
+ GenericUtils.closeIntroPart();
+ GenericUtils.cleanWorkspace();
+ final IProject project = ProjectUtils.createProject("GenericTableTest"); //$NON-NLS-1$
+ PapyrusProjectUtils.copyPapyrusModel(project, Activator.getDefault().getBundle(), "/resources/", MODEL); //$NON-NLS-1$
+ final IFile file = project.getFile(MODEL + "." + SashModel.MODEL_FILE_EXTENSION); //$NON-NLS-1$
+ Assert.assertNotNull(file);
+ papyrusEditor = (CoreMultiDiagramEditor)EditorUtils.openEditor(file);
+ Assert.assertNotNull(papyrusEditor);
+ modelExplorerView = ModelExplorerUtils.openModelExplorerView();
+ final Model root = (Model)ModelExplorerUtils.getRootInModelExplorer(modelExplorerView);
+ class1 = (Class)root.getOwnedMember("Class1"); //$NON-NLS-1$
+ }
+
+ public void setSelectionInTheModelExplorer() {
+ final List<Element> selection = new ArrayList<Element>();
+ selection.add(class1);
+ modelExplorerView.setFocus();
+ ModelExplorerUtils.setSelectionInTheModelexplorer(modelExplorerView, selection);
+ }
+
+ @Test
+ public void handlerActivationTest() {
+ final IHandler handler = HandlerUtils.getActiveHandlerFor(CREATE_GENERIC_UML_TABLE);
+ Assert.assertNotNull(handler);
+ Assert.assertTrue(handler.isEnabled());
+ }
+
+ @Test
+ public void createEmptyTableTest() throws Exception {
+ setSelectionInTheModelExplorer();
+ final Command cmd = HandlerUtils.getCommand(CREATE_GENERIC_UML_TABLE);
+ HandlerUtils.executeCommand(cmd);
+ final PapyrusTable table = getCurrentTable();
+ Assert.assertNotNull(table);
+ final List<EObject> elements = TableWidgetUtils.getElements(table.getTable());
+ Assert.assertTrue("The created table is not empty", elements.isEmpty());
+ }
+
+ protected PapyrusTable getCurrentTable() {
+ final PapyrusTable table = null;
+ return table;
+ }
+
+ protected TransactionalEditingDomain getEditingDomain(){
+ return null;
+ }
+
+
+ @Test
+ public void createTableWithContentsTest() throws Exception {
+ //we create a new table
+ createEmptyTableTest();
+ final PapyrusTable table = getCurrentTable();
+ final Port port1 = UMLFactory.eINSTANCE.createPort();
+ port1.setName("port1");
+ class1.getAllAttributes().add(port1);
+
+ //TODO add this port to the table
+
+ table.setFillingMode(FillingMode.CONTEXT_FEATURE);
+ //there is no feature to listen, so the content of the table should be deleted
+ Assert.assertTrue(table.getTable().getRows().isEmpty());
+ //TODO
+ final EReference ref = UMLPackage.eINSTANCE.getEncapsulatedClassifier_OwnedPort();
+ table.setContextFeature(ref);
+ //the table should now content 1 element
+ EList<Row> rows = table.getTable().getRows();
+ Assert.assertTrue(rows.size()==1);
+ Assert.assertTrue(rows.get(0).getElement()==port1);
+
+ final Port port2 = UMLFactory.eINSTANCE.createPort();
+ port2.setName("port2");
+ class1.getAllAttributes().add(port2);
+
+ rows = table.getTable().getRows();
+ Assert.assertTrue(rows.size()==2);
+ Assert.assertTrue(rows.get(0).getElement()==port1);
+ Assert.assertTrue(rows.get(1).getElement()==port2);
+ }
+
+
+ @Test
+ public void reparentElementTest() throws Exception {
+ createEmptyTableTest();
+ final PapyrusTable table = getCurrentTable();
+ final Port port1 = UMLFactory.eINSTANCE.createPort();
+ port1.setName("port1");
+ class1.getAllAttributes().add(port1);
+
+ //TODO add this port to the table
+
+ table.setFillingMode(FillingMode.CONTEXT_FEATURE);
+ //there is no feature to listen, so the content of the table should be deleted
+ Assert.assertTrue(table.getTable().getRows().isEmpty());
+ //TODO
+ final EReference ref = UMLPackage.eINSTANCE.getEncapsulatedClassifier_OwnedPort();
+ table.setContextFeature(ref);
+ //the table should now content 1 element
+ EList<Row> rows = table.getTable().getRows();
+ Assert.assertTrue(rows.size()==1);
+ Assert.assertTrue(rows.get(0).getElement()==port1);
+
+ Class class2 = UMLFactory.eINSTANCE.createClass();
+ class1.getPackage().getOwnedElements().add(class2);
+
+ //we reparent port1
+ class2.getAllAttributes().add(port1); //TODO verify if it is the best way!
+ rows = table.getTable().getRows();
+ Assert.assertTrue(rows.size()==0);
+ }
+
+ @Test
+ public void destroyElementTest() throws Exception {
+ createEmptyTableTest();
+ final PapyrusTable table = getCurrentTable();
+ final Port port1 = UMLFactory.eINSTANCE.createPort();
+ port1.setName("port1");
+ class1.getAllAttributes().add(port1);
+
+ //TODO add this port to the table
+
+ table.setFillingMode(FillingMode.CONTEXT_FEATURE);
+ //there is no feature to listen, so the content of the table should be deleted
+ Assert.assertTrue(table.getTable().getRows().isEmpty());
+ //TODO
+ final EReference ref = UMLPackage.eINSTANCE.getEncapsulatedClassifier_OwnedPort();
+ table.setContextFeature(ref);
+ //the table should now content 1 element
+ EList<Row> rows = table.getTable().getRows();
+ Assert.assertTrue(rows.size()==1);
+ Assert.assertTrue(rows.get(0).getElement()==port1);
+
+ //TODO destroy Port1
+ }
+
+ @Ignore
+ @Test
+ public void destroyTableTest() {
+//should be moved in a modelexplorer plugin
+ }
+
+ @Ignore
+ @Test
+ public void destroyTableContextTest() {
+ //should be moved in a modelexplorer plugin
+ }
+
+ @AfterClass
+ public static void closeAll() {
+ GenericUtils.closeAllEditors();
+ }
+}

Back to the top