Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml')
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java_bak358
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPastePartTest.java_bak129
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllCopyPasteTests.java_bak28
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllTests.java29
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java63
5 files changed, 607 insertions, 0 deletions
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java_bak b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java_bak
new file mode 100644
index 00000000000..115dc02fe67
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java_bak
@@ -0,0 +1,358 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.modelexplorer.tests.copypaste;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerView;
+import org.eclipse.papyrus.modelexplorer.NavigatorUtils;
+import org.eclipse.papyrus.sysml.modelexplorer.Activator;
+import org.eclipse.papyrus.sysml.modelexplorer.tests.utils.EditorUtils;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.intro.IIntroPart;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Property;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+
+/**
+ * Abstract class for Copy/paste
+ */
+public class AbstractCopyPasteTest {
+
+ /** boolean to indicate if the test is initialized or not */
+ private static boolean isInitialized;
+
+ /** main papyrus editor */
+ public static IEditorPart editor = null;
+
+ /** id of the papyrus editor */
+ public static String editorID = "org.eclipse.papyrus.core.papyrusEditor";
+
+ /** view part: the model explorer */
+ protected static IViewPart modelExplorerPart;
+
+ // EObjects selectable
+ protected static Model modelEObject;
+
+ protected static org.eclipse.uml2.uml.Class b1EObject;
+
+ protected static Property b1_pB2EObject;
+
+ protected static Property b1_pB1P2EObject;
+
+ protected static org.eclipse.uml2.uml.Class b2EObject;
+
+ protected static Package p1EObject;
+
+ protected static org.eclipse.uml2.uml.Class p1_b1p1EObject;
+
+ protected static Property p1_b1p1_pB1EObject;
+
+ protected static Property p1_b1p1_pB2P1EObject;
+
+ protected static org.eclipse.uml2.uml.Class p1_b2p1EObject;
+
+ // end of selectable EObjects
+ /**
+ * Prepare the diagram before testing
+ *
+ * @throws Exception
+ * exception thrown in case of problem
+ */
+ @BeforeClass
+ public static void prepareTest() throws Exception {
+ DiagramEditPart diagramEditPart = EditorUtils.getDiagramEditPart();
+ EObject root = diagramEditPart.getDiagramView().getElement();
+
+ Assert.assertTrue("Impossible to find main model", root instanceof Model);
+ modelEObject = (Model)root;
+ b1EObject = (Class)modelEObject.getPackagedElement("B1");
+ Assert.assertNotNull(b1EObject);
+ b1_pB2EObject = b1EObject.getPart("pB2", null);
+ Assert.assertNotNull(b1_pB2EObject);
+ b1_pB1P2EObject = b1EObject.getPart("pB1P1", null);
+ Assert.assertNotNull(b1_pB1P2EObject);
+ b2EObject = (Class)modelEObject.getPackagedElement("B2");
+ Assert.assertNotNull(b2EObject);
+ p1EObject = (Package)modelEObject.getPackagedElement("P1");
+ Assert.assertNotNull(p1EObject);
+ p1_b1p1EObject = (Class)p1EObject.getPackagedElement("B1P1");
+ Assert.assertNotNull(p1_b1p1EObject);
+ p1_b1p1_pB1EObject = p1_b1p1EObject.getPart("pB1", null);
+ Assert.assertNotNull(p1_b1p1_pB1EObject);
+ p1_b1p1_pB2P1EObject = p1_b1p1EObject.getPart("pB2P1", null);
+ Assert.assertNotNull(p1_b1p1_pB2P1EObject);
+ p1_b2p1EObject = (Class)p1EObject.getPackagedElement("B2P1");
+ Assert.assertNotNull(p1_b2p1EObject);
+ }
+
+ /**
+ * Initialization of the test
+ *
+ * @throws Exception
+ * thrown when initialization has problem
+ */
+ @BeforeClass
+ public static void openPapyrusWithAnEmptyProject() throws Exception {
+ IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
+ PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
+ // Prepare new project for tests
+ IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
+ if(!testProject.exists()) {
+ testProject.create(new NullProgressMonitor());
+ }
+
+ if(!testProject.isOpen()) {
+ testProject.open(new NullProgressMonitor());
+ }
+
+ // Copy EmptyModel from bundle to the test project
+ IFile emptyModel_di = testProject.getFile("ModelWithBDD.di");
+ IFile emptyModel_no = testProject.getFile("ModelWithBDD.notation");
+ IFile emptyModel_uml = testProject.getFile("ModelWithBDD.uml");
+
+ // isInitialized = isInitialized || emptyModel_di.exists();
+
+ if(!isInitialized) {
+ isInitialized = true;
+ emptyModel_di.create(Activator.getDefault().getBundle().getResource("/model/ModelWithBDD.di").openStream(), true, new NullProgressMonitor());
+ emptyModel_no.create(Activator.getDefault().getBundle().getResource("/model/ModelWithBDD.notation").openStream(), true, new NullProgressMonitor());
+ emptyModel_uml.create(Activator.getDefault().getBundle().getResource("/model/ModelWithBDD.uml").openStream(), true, new NullProgressMonitor());
+ }
+
+ // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ editor = page.openEditor(new FileEditorInput(emptyModel_di), editorID);
+
+ modelExplorerPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ModelExplorerPageBookView.VIEW_ID);
+ Assert.assertNotNull("Model explorer is null", modelExplorerPart);
+ }
+
+ /**
+ * Close editor
+ *
+ * @throws Exception
+ * exception thrown in case of problem
+ */
+ @AfterClass
+ public static void closePapyrusAndCleanProject() throws Exception {
+ // Close the editor without saving content created during tests
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeEditor(editor, false);
+ }
+
+
+ /**
+ * Selects and reveal the specified element
+ *
+ * @param object
+ * the object to select
+ * @throws Exception
+ * exception thrown in case element could not be selected
+ */
+ public static void selectAndReveal(EObject object) throws Exception {
+ selectAndReveal(Arrays.asList(object));
+ }
+
+ /**
+ * Selects and reveal the specified list of elements
+ *
+ * @param newElements
+ * the list of objects to select
+ * @throws Exception
+ * exception thrown in case element could not be selected
+ */
+ public static void selectAndReveal(List<EObject> newElements) throws Exception {
+ // Retrieve model explorer
+ ModelExplorerView modelExplorerView = null;
+
+ ModelExplorerPageBookView bookViewPart = (ModelExplorerPageBookView)NavigatorUtils.findViewPart(ModelExplorerPageBookView.VIEW_ID); //$NON-NLS-0$
+ if(bookViewPart != null) {
+ modelExplorerView = (ModelExplorerView)((ModelExplorerPageBookView)bookViewPart).getActiveView();
+ }
+
+ // Set selection on new element in the model explorer
+ if((modelExplorerView != null) && (newElements != null)) {
+ List<EObject> semanticElementList = new ArrayList<EObject>();
+ semanticElementList.addAll(newElements);
+ modelExplorerView.revealSemanticElement(semanticElementList);
+ } else {
+ throw new Exception("Impossible to find the model explorer required to select: " + newElements);
+ }
+ }
+
+ /**
+ * Generic implementation of the test
+ *
+ * @throws Exception
+ * exception thrown when the test has problems
+ */
+ protected void testExecutableCopyPaste(EObject targetContainer, EObject copiedEObject, EStructuralFeature feature) throws Exception {
+ // retrieve elements in the model explorer
+ selectAndReveal(targetContainer);
+
+ List<EObject> originalValues = new ArrayList<EObject>((List<EObject>)targetContainer.eGet(feature));
+
+ Map<Object, Object> originalModel = new HashMap<Object, Object>();
+ initializeTest(originalModel, targetContainer, copiedEObject);
+
+ // try to paste in several places
+ // copy Paste b1EObject
+ ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+ commandService.refreshElements(IWorkbenchCommandConstants.EDIT_PASTE, null);
+ org.eclipse.core.commands.Command pasteCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_PASTE);
+ Assert.assertNotNull("Impossible to find paste command", pasteCommand);
+ Assert.assertTrue("command in not enabled", pasteCommand.isEnabled());
+ Assert.assertTrue("command in not defined", pasteCommand.isDefined());
+
+ pasteCommand.executeWithChecks(new ExecutionEvent());
+
+ // check editor state (should be non dirty)
+ Assert.assertTrue("Editor should be dirty after paste command execution", isEditorDirty());
+
+
+ // should retrieve a new Part AND a new association
+ List<EObject> newValues = (List<EObject>)targetContainer.eGet(feature);
+ // size = original size +1
+ Assert.assertEquals("Wrong number of attributes after paste", originalValues.size() + 1, newValues.size());
+
+ // check the new one has a property
+ Iterator<EObject> it = newValues.iterator();
+ EObject newValue = null;
+ while(it.hasNext()) {
+ EObject value = it.next();
+ if(!originalValues.contains(value)) {
+ newValue = value;
+ }
+ }
+
+ Assert.assertNotNull("Impossible to find the new Part", newValue);
+
+ // part should be linked to an association
+ postCopyAdditionalChecks(originalModel, newValue);
+
+ // undo
+ if(getEditingDomain().getCommandStack().canUndo()) {
+ getEditingDomain().getCommandStack().undo();
+ } else {
+ throw new Exception("Impossible to undo the paste command: " + pasteCommand);
+ }
+ // check editor state (should be non dirty)
+ Assert.assertTrue("Editor should not be dirty after undo", isEditorDirty());
+ // check old values equals the actual values
+ newValues = (List<EObject>)targetContainer.eGet(feature);
+ Assert.assertEquals("Initial and current list feature list should be equivalent", newValues, originalValues);
+
+ // redo
+ if(getEditingDomain().getCommandStack().canRedo()) {
+ getEditingDomain().getCommandStack().redo();
+ } else {
+ throw new Exception("Impossible to redo the paste command: " + pasteCommand);
+ }
+ // check editor state (should be non dirty)
+ Assert.assertFalse("Editor should not dirty after redo", isEditorDirty());
+
+ // check as it was the result of the paste command
+ newValues = (List<EObject>)targetContainer.eGet(feature);
+ // size = 3
+ Assert.assertEquals("Wrong number of attributes after paste", originalValues.size() + 1, newValues.size());
+
+ // check the new one has a property
+ it = newValues.iterator();
+ newValue = null;
+ while(it.hasNext()) {
+ EObject value = it.next();
+ if(!originalValues.contains(value)) {
+ newValue = value;
+ }
+ }
+ Assert.assertNotNull("Impossible to find the new Part", newValue);
+
+ // part should be linked to an association
+ postCopyAdditionalChecks(originalModel, newValue);
+
+ // undo again, to restore state
+ if(getEditingDomain().getCommandStack().canUndo()) {
+ getEditingDomain().getCommandStack().undo();
+ } else {
+ throw new Exception("Impossible to re-undo the paste command: " + pasteCommand);
+ }
+ // check editor state (should be non dirty)
+ Assert.assertTrue("Editor should not be dirty after undo", isEditorDirty());
+
+ }
+
+ /**
+ * executes additional checks on the new value
+ *
+ * @param originalModel
+ * the map containing all values stored before launching the test
+ * @param newValue
+ * the new value, result of the copy
+ */
+ protected void postCopyAdditionalChecks(Map<?, ?> originalModel, EObject newValue) throws Exception {
+ // use the values contained in the map to do additional checks
+ }
+
+ protected void initializeTest(Map<Object, Object> additionalChecks, EObject targetContainer, EObject copiedEObject) {
+ // nothing to do here
+ }
+
+ /**
+ * Returns the current editing domain
+ *
+ * @return
+ * the current editing domain
+ */
+ protected TransactionalEditingDomain getEditingDomain() throws Exception {
+ return org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ }
+
+ /**
+ * Returns <code>true</code> if the current Active editor is dirty.
+ *
+ * @return <code>true</code> if the current Active editor is dirty
+ * @throws Exception
+ * exception thrown in case of problem (NPE, etc.)
+ */
+ protected boolean isEditorDirty() throws Exception {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().isDirty();
+ }
+}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPastePartTest.java_bak b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPastePartTest.java_bak
new file mode 100644
index 00000000000..c32b1b55815
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPastePartTest.java_bak
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.modelexplorer.tests.copypaste;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test for Copy / Paste of a Part
+ */
+public class CopyPastePartTest extends AbstractCopyPasteTest {
+
+ /**
+ * prepare the copy
+ *
+ * @throws Exception
+ * exception thrown in case of problems
+ */
+ @Before
+ public void testPrepare() throws Exception {
+ // check editor state (should be non dirty)
+ Assert.assertFalse("Editor should not be dirty at initialization", isEditorDirty());
+ // retrieve elements in the model explorer
+ selectAndReveal(pB2_B1_EObject);
+
+ // copy Paste b1EObject
+ ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+ commandService.refreshElements(IWorkbenchCommandConstants.EDIT_COPY, null);
+ org.eclipse.core.commands.Command copyCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_COPY);
+ Assert.assertNotNull("Impossible to find copy command", copyCommand);
+ Assert.assertTrue("command in not enabled", copyCommand.isEnabled());
+ Assert.assertTrue("command in not defined", copyCommand.isDefined());
+ copyCommand.executeWithChecks(new ExecutionEvent());
+
+ // check editor state (should be non dirty)
+ // Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty());
+
+ // NOTE: save editor. The copy command should not dirty the model, the implementation of the copy command or the editor should be modified
+ Assert.assertTrue("Copy command is dirtying the model, whereas it should not. This assert is here to remember that the test code should be modified: Isdirty = false after copy...", isEditorDirty());
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Assert.assertFalse("Save command is non-dirtying the model, whereas it should. ", isEditorDirty());
+ // END NOTE
+ }
+
+ @Override
+ protected void initializeTest(Map<Object, Object> additionalChecks, EObject targetContainer, EObject copiedEObject) {
+ super.initializeTest(additionalChecks, targetContainer, copiedEObject);
+ // nothing here
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void postCopyAdditionalChecks(Map<?, ?> originalModel, EObject newValue) throws Exception {
+ super.postCopyAdditionalChecks(originalModel, newValue);
+
+ Association newAssociation = ((Property)newValue).getAssociation();
+ Assert.assertNotNull("New Part should have an association", newAssociation);
+
+ }
+
+ /**
+ * Test the copy /paste of a part
+ *
+ * @throws Exception
+ * exception thrown in case of problems
+ */
+ @Test
+ public void testPastePartInBlockB1() throws Exception {
+ testExecutableCopyPaste(b1_EObject, pB2_B1_EObject, UMLPackage.eINSTANCE.getClassifier_Attribute());
+ }
+
+ /**
+ * Test the copy /paste of a part
+ *
+ * @throws Exception
+ * exception thrown in case of problems
+ */
+ @Test
+ public void testPastePartInBlockB2() throws Exception {
+ testExecutableCopyPaste(b2_EObject, pB2_B1_EObject, UMLPackage.eINSTANCE.getClassifier_Attribute());
+ }
+
+ /**
+ * Test the copy /paste of a part
+ *
+ * @throws Exception
+ * exception thrown in case of problems
+ */
+ @Test
+ public void testPastePartInBlockB1P1() throws Exception {
+ testExecutableCopyPaste(b1P1_P1_EObject, pB2_B1_EObject, UMLPackage.eINSTANCE.getClassifier_Attribute());
+ }
+
+ /**
+ * Test the copy /paste of a part
+ *
+ * @throws Exception
+ * exception thrown in case of problems
+ */
+ @Test
+ public void testPastePartInBlockB2P1() throws Exception {
+ testExecutableCopyPaste(b2P1_P1_EObject, pB2_B1_EObject, UMLPackage.eINSTANCE.getClassifier_Attribute());
+ }
+}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllCopyPasteTests.java_bak b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllCopyPasteTests.java_bak
new file mode 100644
index 00000000000..285238bbc47
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllCopyPasteTests.java_bak
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.modelexplorer.tests.suites;
+
+import org.eclipse.papyrus.sysml.modelexplorer.tests.copypaste.CopyPasteSimplePartTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+/**
+ *
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ CopyPasteSimplePartTest.class, })
+public class AllCopyPasteTests {
+
+}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllTests.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllTests.java
new file mode 100644
index 00000000000..7ab6b62e4fa
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/suites/AllTests.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.modelexplorer.tests.suites;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+/**
+ * Main test suite class
+ */
+@RunWith(Suite.class)
+@SuiteClasses({
+ AllCopyPasteTests.class,
+})
+public class AllTests {
+
+}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
new file mode 100644
index 00000000000..edfe37f104d
--- /dev/null
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.modelexplorer.tests.utils;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.services.ServicesRegistry;
+import org.eclipse.papyrus.core.utils.ServiceUtils;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Utility class for tests
+ */
+public class EditorUtils {
+
+ /**
+ * Retrieves current active editor
+ *
+ * @return current active editor
+ * @throws Exception
+ * exception thrown in case of issue
+ */
+ public static IEditorPart getEditor() throws Exception {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ }
+
+ public static DiagramEditor getDiagramEditor() throws Exception {
+
+ ServicesRegistry serviceRegistry = (ServicesRegistry)getEditor().getAdapter(ServicesRegistry.class);
+ try {
+ return (DiagramEditor)ServiceUtils.getInstance().getNestedActiveIEditorPart(serviceRegistry);
+
+ } catch (ServiceException e) {
+ throw new Exception("Unable to retrieve service.", e);
+ } catch (ClassCastException e) {
+ throw new Exception("Active diagram is not a DiagramEditor." + e.getMessage(), e);
+ }
+ }
+
+ public static DiagramEditPart getDiagramEditPart() throws Exception {
+
+ try {
+ return getDiagramEditor().getDiagramEditPart();
+
+ } catch (NullPointerException e) {
+ throw new Exception("Could not find diagram edit part.", e);
+ }
+ }
+
+}

Back to the top