Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/tests/DefaultDiagramCopyCommandTest.java')
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/tests/DefaultDiagramCopyCommandTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/tests/DefaultDiagramCopyCommandTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/tests/DefaultDiagramCopyCommandTest.java
new file mode 100644
index 00000000000..655618bfc20
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/tests/DefaultDiagramCopyCommandTest.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.commands.tests;
+
+import static java.util.Collections.singletonList;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.commands.DefaultDiagramCopyCommand;
+import org.eclipse.papyrus.junit.utils.rules.ActiveDiagram;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Tests for the {@link DefaultDiagramCopyCommand} class.
+ */
+@PluginResource("models/ExpansionModelTest.di")
+@ActiveDiagram("NewDiagram")
+public class DefaultDiagramCopyCommandTest {
+
+ private final PapyrusEditorFixture editor = new PapyrusEditorFixture();
+
+ @Rule
+ public final CustomUMLFactoryFixture fixture = new CustomUMLFactoryFixture(editor);
+
+ @Rule
+ public final PapyrusClipboardFixture clipboard = new PapyrusClipboardFixture();
+
+ @Test
+ public void copyElement() {
+ org.eclipse.uml2.uml.Class myClass = (org.eclipse.uml2.uml.Class) editor.getModel().getOwnedType("MyClass");
+ IGraphicalEditPart editPart = (IGraphicalEditPart) editor.findEditPart(myClass);
+ fixture.reset();
+
+ new DefaultDiagramCopyCommand(editor.getEditingDomain(), clipboard, singletonList(editPart)).dispose();
+
+ // The copied class has its name set via a structural feature setting
+ fixture.assertInvocation("eSetting");
+
+ assertThat(clipboard.getCopyFromSource(myClass), instanceOf(org.eclipse.uml2.uml.Class.class));
+ org.eclipse.uml2.uml.Class copy = (org.eclipse.uml2.uml.Class) clipboard.getCopyFromSource(myClass);
+ assertThat(copy.getName(), containsString(myClass.getName()));
+ }
+
+}

Back to the top