Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2016-11-25 15:46:17 +0000
committerFlorian Barbin2016-11-28 15:29:18 +0000
commit33bddafbffcbb739c0937cfaaca7fbaa8cd05528 (patch)
treeab985c930f72c3a699a2721911bde7a3494f867a
parent605dee44afab884e9cf545138edf99b976cfbb00 (diff)
downloadorg.eclipse.sirius-33bddafbffcbb739c0937cfaaca7fbaa8cd05528.tar.gz
org.eclipse.sirius-33bddafbffcbb739c0937cfaaca7fbaa8cd05528.tar.xz
org.eclipse.sirius-33bddafbffcbb739c0937cfaaca7fbaa8cd05528.zip
[508135] Adds JUnit test
Bug: 508135 Cherry-picked-from: 508106 Change-Id: I2f2d372bd4ba9b75676e4459e8288c7024f59b26 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.aird59
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.ecore6
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.odesign44
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java14
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/UndoAfterInconsistentEdgeCreationViewTest.java112
5 files changed, 229 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.aird
new file mode 100644
index 0000000000..ac252fb98b
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.aird
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<viewpoint:DAnalysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" 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/sirius/diagram/description/style/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style" xmi:id="_9HuvYLVLEeaYufe9whDDtg" selectedViews="_9rx3oLVLEeaYufe9whDDtg" version="10.1.6.201608121430">
+ <semanticResources>dEdgeUndoDangling.ecore</semanticResources>
+ <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_9rx3oLVLEeaYufe9whDDtg">
+ <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="__C6psLVLEeaYufe9whDDtg" name="diagram">
+ <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="__C6psbVLEeaYufe9whDDtg" source="DANNOTATION_CUSTOMIZATION_KEY">
+ <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="__C6psrVLEeaYufe9whDDtg"/>
+ </ownedAnnotationEntries>
+ <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="__DM9kLVLEeaYufe9whDDtg" source="GMF_DIAGRAMS">
+ <data xmi:type="notation:Diagram" xmi:id="__DM9kbVLEeaYufe9whDDtg" type="Sirius" element="__C6psLVLEeaYufe9whDDtg" measurementUnit="Pixel">
+ <children xmi:type="notation:Node" xmi:id="__DWukLVLEeaYufe9whDDtg" type="2001" element="__C6ps7VLEeaYufe9whDDtg">
+ <children xmi:type="notation:Node" xmi:id="__DmmMLVLEeaYufe9whDDtg" type="5002">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="__DmmMbVLEeaYufe9whDDtg" y="5"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="__DtT4LVLEeaYufe9whDDtg" type="3003" element="__C6ptLVLEeaYufe9whDDtg">
+ <styles xmi:type="notation:ShapeStyle" xmi:id="__DtT4bVLEeaYufe9whDDtg" fontName="Cantarell"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__DtT4rVLEeaYufe9whDDtg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="__DWukbVLEeaYufe9whDDtg" fontName="Cantarell" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__DWukrVLEeaYufe9whDDtg" width="30" height="30"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="__DsFwLVLEeaYufe9whDDtg" type="2001" element="__C6ptbVLEeaYufe9whDDtg">
+ <children xmi:type="notation:Node" xmi:id="__DsFw7VLEeaYufe9whDDtg" type="5002">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="__DsFxLVLEeaYufe9whDDtg" y="5"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="__Dt68LVLEeaYufe9whDDtg" type="3003" element="__C6ptrVLEeaYufe9whDDtg">
+ <styles xmi:type="notation:ShapeStyle" xmi:id="__Dt68bVLEeaYufe9whDDtg" fontName="Cantarell"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__Dt68rVLEeaYufe9whDDtg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="__DsFwbVLEeaYufe9whDDtg" fontName="Cantarell" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="__DsFwrVLEeaYufe9whDDtg" x="96" width="30" height="30"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="__DM9krVLEeaYufe9whDDtg"/>
+ </data>
+ </ownedAnnotationEntries>
+ <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="__C6ps7VLEeaYufe9whDDtg" name="ClassA" width="3" height="3" resizeKind="NSEW">
+ <target xmi:type="ecore:EClass" href="dEdgeUndoDangling.ecore#//ClassA"/>
+ <semanticElements xmi:type="ecore:EClass" href="dEdgeUndoDangling.ecore#//ClassA"/>
+ <ownedStyle xmi:type="diagram:Square" xmi:id="__C6ptLVLEeaYufe9whDDtg" labelPosition="node">
+ <description xmi:type="style:SquareDescription" href="dEdgeUndoDangling.odesign#//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@nodeMappings[name='EClazz']/@style"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:NodeMapping" href="dEdgeUndoDangling.odesign#//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@nodeMappings[name='EClazz']"/>
+ </ownedDiagramElements>
+ <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="__C6ptbVLEeaYufe9whDDtg" name="ClassB" width="3" height="3" resizeKind="NSEW">
+ <target xmi:type="ecore:EClass" href="dEdgeUndoDangling.ecore#//ClassB"/>
+ <semanticElements xmi:type="ecore:EClass" href="dEdgeUndoDangling.ecore#//ClassB"/>
+ <ownedStyle xmi:type="diagram:Square" xmi:id="__C6ptrVLEeaYufe9whDDtg" labelPosition="node">
+ <description xmi:type="style:SquareDescription" href="dEdgeUndoDangling.odesign#//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@nodeMappings[name='EClazz']/@style"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:NodeMapping" href="dEdgeUndoDangling.odesign#//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@nodeMappings[name='EClazz']"/>
+ </ownedDiagramElements>
+ <description xmi:type="description_1:DiagramDescription" href="dEdgeUndoDangling.odesign#//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']"/>
+ <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="__C6pt7VLEeaYufe9whDDtg"/>
+ <activatedLayers xmi:type="description_1:Layer" href="dEdgeUndoDangling.odesign#//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer"/>
+ <target xmi:type="ecore:EPackage" href="dEdgeUndoDangling.ecore#/"/>
+ </ownedRepresentations>
+ <viewpoint xmi:type="description:Viewpoint" href="dEdgeUndoDangling.odesign#//@ownedViewpoints[name='dEdgeUndoDangling']"/>
+ </ownedViews>
+</viewpoint:DAnalysis>
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.ecore
new file mode 100644
index 0000000000..3009f2803d
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.ecore
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="package" nsURI="http://package" nsPrefix="package">
+ <eClassifiers xsi:type="ecore:EClass" name="ClassA"/>
+ <eClassifiers xsi:type="ecore:EClass" name="ClassB"/>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.odesign
new file mode 100644
index 0000000000..d2776f5bfb
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.odesign
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="My" version="10.1.3.201511131800">
+ <ownedViewpoints name="dEdgeUndoDangling" modelFileExtension="*.ecore">
+ <ownedRepresentations xsi:type="description_1:DiagramDescription" name="Package" domainClass="ecore.EPackage" enablePopupBars="true">
+ <metamodel href="http://www.eclipse.org/emf/2002/Ecore#/"/>
+ <defaultLayer name="Default">
+ <nodeMappings name="EClazz" semanticCandidatesExpression="feature:eContents" domainClass="ecore.EClass">
+ <style xsi:type="style:SquareDescription" labelPosition="node" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </nodeMappings>
+ <edgeMappings name="ReferenceInvalid" preconditionExpression="false" sourceMapping="//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@nodeMappings[name='EClazz']" targetMapping="//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@nodeMappings[name='EClazz']" targetFinderExpression="feature:eType" sourceFinderExpression="feature:eContainer" domainClass="EReference" useDomainElement="true">
+ <style sizeComputationExpression="2">
+ <strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ <centerLabelStyleDescription>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ </centerLabelStyleDescription>
+ </style>
+ </edgeMappings>
+ <toolSections>
+ <ownedTools xsi:type="tool:EdgeCreationDescription" name="Create Reference" edgeMappings="//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@edgeMappings[name='ReferenceInvalid']">
+ <sourceVariable name="source"/>
+ <targetVariable name="target"/>
+ <sourceViewVariable name="sourceView"/>
+ <targetViewVariable name="targetView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:source">
+ <subModelOperations xsi:type="tool_1:CreateInstance" typeName="EReference" referenceName="eStructuralFeatures">
+ <subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:instance">
+ <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="toto"/>
+ <subModelOperations xsi:type="tool_1:SetValue" featureName="eType" valueExpression="var:target"/>
+ <subModelOperations xsi:type="tool:CreateEdgeView" mapping="//@ownedViewpoints[name='dEdgeUndoDangling']/@ownedRepresentations[name='Package']/@defaultLayer/@edgeMappings[name='ReferenceInvalid']" containerViewExpression="[sourceView.eContainer()/]" sourceExpression="var:source" targetExpression="var:target"/>
+ </subModelOperations>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ </toolSections>
+ </defaultLayer>
+ </ownedRepresentations>
+ </ownedViewpoints>
+</description:Group>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
index e9b4c03d5f..49264335e9 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES.
* 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
@@ -10,11 +10,6 @@
*******************************************************************************/
package org.eclipse.sirius.tests.suite.diagram;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
import org.eclipse.core.runtime.Platform;
import org.eclipse.sirius.tests.suite.diagram.sequence.AllSequenceDiagramsPluginTests;
import org.eclipse.sirius.tests.support.api.TestsUtil;
@@ -222,6 +217,7 @@ import org.eclipse.sirius.tests.unit.diagram.tools.NoteBehaviorOnHideRevealDelet
import org.eclipse.sirius.tests.unit.diagram.tools.PartAndLabelPartSelectionDeletionTest;
import org.eclipse.sirius.tests.unit.diagram.tools.SelectionAfterToolExecutionTest;
import org.eclipse.sirius.tests.unit.diagram.tools.ToolsApplicabilityTest;
+import org.eclipse.sirius.tests.unit.diagram.tools.UndoAfterInconsistentEdgeCreationViewTest;
import org.eclipse.sirius.tests.unit.diagram.tools.palette.ModifySessionOutsideEclipseTest;
import org.eclipse.sirius.tests.unit.diagram.tools.palette.PaletteManagerWithFiltersTest;
import org.eclipse.sirius.tests.unit.diagram.tools.palette.PaletteManagerWithLayersTest;
@@ -238,6 +234,11 @@ import org.eclipse.sirius.tests.unit.perf.diagram.refresh.connections.DCompartme
import org.eclipse.sirius.tests.unit.table.unit.migration.InitializeElementsToSelectExpressionForTableMigrationTest;
import org.eclipse.sirius.tests.unit.table.unit.tools.SelectionInTableAfterToolExecutionTest;
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
public class AllDiagramPluginsTests {
/**
@@ -388,6 +389,7 @@ public class AllDiagramPluginsTests {
// tools
suite.addTestSuite(ToolsApplicabilityTest.class);
suite.addTestSuite(EdgeCreationToolWithExtraMappingTest.class);
+ suite.addTestSuite(UndoAfterInconsistentEdgeCreationViewTest.class);
suite.addTestSuite(CreationTest.class);
suite.addTestSuite(CreateViewWithMappingImportTests.class);
suite.addTestSuite(NoteBehaviorOnHideRevealDeleteElementTest.class);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/UndoAfterInconsistentEdgeCreationViewTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/UndoAfterInconsistentEdgeCreationViewTest.java
new file mode 100644
index 0000000000..981161e350
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/UndoAfterInconsistentEdgeCreationViewTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2016 THALES GLOBAL SERVICES.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.unit.diagram.tools;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.DNode;
+import org.eclipse.sirius.tests.SiriusTestsPlugin;
+import org.eclipse.sirius.tests.support.api.SiriusDiagramTestCase;
+import org.eclipse.sirius.tests.support.api.TestsUtil;
+import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
+import org.eclipse.sirius.ui.business.api.preferences.SiriusUIPreferencesKeys;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * Test that performing an undo after an edge creation tool doesn't lead to
+ * dangling references on {@link DNode#getOutgoingEdges()} and
+ * {@link DNode#getIncomingEdges()}. See #508138 more details.
+ *
+ * @author Florian Barbin
+ *
+ */
+public class UndoAfterInconsistentEdgeCreationViewTest extends SiriusDiagramTestCase {
+
+ private static final String REFERENCE_CREATE_TOOL_NAME = "Create Reference";
+
+ private static final String EDGE_PB_REPRESENTATION_DESC_NAME = "Package";
+
+ private static final String SEMANTIC_MODEL_PATH = "/" + SiriusTestsPlugin.PLUGIN_ID + "/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.ecore";
+
+ private static final String SESSION_MODEL_PATH = "/" + SiriusTestsPlugin.PLUGIN_ID + "/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.aird";
+
+ private static final String MODELER_PATH = "/" + SiriusTestsPlugin.PLUGIN_ID + "/data/unit/tools/undoEdgeCreationToolDangling/dEdgeUndoDangling.odesign";
+
+ private DDiagram diagram;
+
+ private DiagramEditor editor;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ TestsUtil.emptyEventsFromUIThread();
+
+ genericSetUp(SEMANTIC_MODEL_PATH, MODELER_PATH, SESSION_MODEL_PATH);
+
+ changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);
+ changeSiriusPreference(SiriusUIPreferencesKeys.PREF_REFRESH_ON_REPRESENTATION_OPENING.name(), true);
+
+ DialectUIManager.INSTANCE.closeEditor(editor, false);
+ TestsUtil.synchronizationWithUIThread();
+ diagram = (DDiagram) getRepresentations(EDGE_PB_REPRESENTATION_DESC_NAME).toArray()[0];
+ assertNotNull(diagram);
+ editor = (DiagramEditor) DialectUIManager.INSTANCE.openEditor(session, diagram, new NullProgressMonitor());
+ TestsUtil.synchronizationWithUIThread();
+ assertNotNull(editor);
+ }
+
+ /**
+ * This test performs the following actions:
+ * <ul>
+ * <li>Create an edge using the edge creation tool.</li>
+ * <li>Check that this edge has been removed by the refresh. Indeed, this
+ * edge creation tool create a new DEdge inconsistent with the edge mapping
+ * precondition (always false)</li>
+ * <li>Perform an undo</li>
+ * <li>Make sure there is still no DEdge in the diagram and the DNodes do
+ * not have references toward a detached DEdge.</li>
+ * </ul>
+ *
+ * @throws Exception
+ * if an error occurs during the undo.
+ */
+ public void testEdgeEditPartCreationAfterFilterDeactivation() throws Exception {
+ List<DNode> nodeClasses = Lists.newArrayList(Iterables.filter(diagram.getDiagramElements(), DNode.class));
+ assertEquals("Bad input data : wrong class number", 2, nodeClasses.size());
+ DNode class1 = nodeClasses.get(0);
+ DNode class2 = nodeClasses.get(1);
+ applyEdgeCreationTool(REFERENCE_CREATE_TOOL_NAME, diagram, class1, class2);
+ assertEquals("The refresh should have removed the created DEdge", 0, diagram.getEdges().size());
+ assertEquals("The refresh should have removed the created DEdge", 0, class1.getOutgoingEdges().size());
+ assertEquals("The refresh should have removed the created DEdge", 0, class2.getIncomingEdges().size());
+ undo();
+ assertEquals("After undo, there should be no DEdge in the diagram", 0, diagram.getEdges().size());
+ assertEquals("After undo, the DNode should not reference any edges", 0, class1.getOutgoingEdges().size());
+ assertEquals("After undo, the DNode should not reference any edges", 0, class2.getIncomingEdges().size());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ DialectUIManager.INSTANCE.closeEditor(editor, false);
+ TestsUtil.synchronizationWithUIThread();
+ diagram = null;
+ editor = null;
+ super.tearDown();
+ }
+
+}

Back to the top