Skip to main content
aboutsummaryrefslogtreecommitdiffstats
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/tests/ExpansionAddLink.java')
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java72
1 files changed, 38 insertions, 34 deletions
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java
index cbc75a86b42..800a55f5eed 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
+ * Copyright (c) 2015, 2016 CEA LIST, 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
@@ -8,6 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
@@ -29,8 +30,8 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.elementtypesconfigurations.registries.ElementTypeConfigurationTypeRegistry;
import org.eclipse.papyrus.infra.gmfdiag.common.SynchronizableGmfDiagramEditor;
@@ -38,6 +39,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.expansion.ChildrenListRepresenta
import org.eclipse.papyrus.infra.gmfdiag.common.expansion.DiagramExpansionSingleton;
import org.eclipse.papyrus.infra.gmfdiag.common.expansion.DiagramExpansionsRegistry;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest;
import org.junit.Assert;
import org.junit.Test;
@@ -49,7 +51,7 @@ import org.osgi.framework.Bundle;
*
*
*/
-public class ExpansionAddLink extends AbstractEditorTest{
+public class ExpansionAddLink extends AbstractEditorTest {
public void openDiagram(IMultiDiagramEditor editor, final String name) {
@@ -58,7 +60,7 @@ public class ExpansionAddLink extends AbstractEditorTest{
ModelSet modelSet = ServiceUtils.getInstance().getModelSet(editor.getServicesRegistry());
NotationModel notation = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID);
Diagram diagram = notation.getDiagram(name);
- ServiceUtils.getInstance().getIPageManager(editor.getServicesRegistry()).openPage(diagram);
+ ServiceUtils.getInstance().getService(IPageManager.class, editor.getServicesRegistry()).openPage(diagram);
flushDisplayEvents();
} catch (Exception e) {
throw new IllegalStateException("Cannot initialize test", e);
@@ -72,40 +74,40 @@ public class ExpansionAddLink extends AbstractEditorTest{
@Test
public void load_DiagramExpansion() {
- //loading
- DiagramExpansionsRegistry diagramExpansionsRegistry= loadXMIExpansionModel("AddLink.xmi");
- Assert.assertEquals("Size ot the registry must be equals to 1",1,diagramExpansionsRegistry.getDiagramExpansions().size());
- Assert.assertEquals("Size ot the map childreen must be equals to 1",1,diagramExpansionsRegistry.mapChildreen.size());
+ // loading
+ DiagramExpansionsRegistry diagramExpansionsRegistry = loadXMIExpansionModel("AddLink.xmi");
+ Assert.assertEquals("Size ot the registry must be equals to 1", 1, diagramExpansionsRegistry.getDiagramExpansions().size());
+ Assert.assertEquals("Size ot the map childreen must be equals to 1", 1, diagramExpansionsRegistry.mapChildreen.size());
- //test the data structure that is interpreted by the framework
- ChildrenListRepresentation childrenListRepresentation= diagramExpansionsRegistry.mapChildreen.get(CLASS_DIAGRAM_TYPE);
+ // test the data structure that is interpreted by the framework
+ ChildrenListRepresentation childrenListRepresentation = diagramExpansionsRegistry.mapChildreen.get(CLASS_DIAGRAM_TYPE);
System.out.println(childrenListRepresentation);
- Assert.assertNotNull("A usage contex has been defined for "+CLASS_DIAGRAM_TYPE , childrenListRepresentation);
-
- Assert.assertNotNull("The Link of NewDependency has been added",childrenListRepresentation.IDMap.get(DEPENDENCY_HINT));
- List<String> the_ClassDiagram_Children=childrenListRepresentation.parentChildrenRelation.get(CLASS_DIAGRAM_TYPE);
- Assert.assertEquals("The class Diagram can have a new child",1, the_ClassDiagram_Children.size());
- Assert.assertEquals("class Diagram has to contain "+DEPENDENCY_HINT,DEPENDENCY_HINT, the_ClassDiagram_Children.get(0));
+ Assert.assertNotNull("A usage contex has been defined for " + CLASS_DIAGRAM_TYPE, childrenListRepresentation);
-
- // the model is valid
- //now launch a class diagram
+ Assert.assertNotNull("The Link of NewDependency has been added", childrenListRepresentation.IDMap.get(DEPENDENCY_HINT));
+ List<String> the_ClassDiagram_Children = childrenListRepresentation.parentChildrenRelation.get(CLASS_DIAGRAM_TYPE);
+ Assert.assertEquals("The class Diagram can have a new child", 1, the_ClassDiagram_Children.size());
+ Assert.assertEquals("class Diagram has to contain " + DEPENDENCY_HINT, DEPENDENCY_HINT, the_ClassDiagram_Children.get(0));
+
+
+ // the model is valid
+ // now launch a class diagram
try {
initModel("ExpansionModelProject", "ExpansionModelTest", getBundle());
openDiagram(editor, "NewDiagram");
- SynchronizableGmfDiagramEditor diagramEditor = (SynchronizableGmfDiagramEditor)editor.getActiveEditor();
- DiagramEditPart diagramEditPart = (DiagramEditPart)editor.getAdapter(DiagramEditPart.class);
+ SynchronizableGmfDiagramEditor diagramEditor = (SynchronizableGmfDiagramEditor) editor.getActiveEditor();
+ DiagramEditPart diagramEditPart = editor.getAdapter(DiagramEditPart.class);
Assert.assertNotNull("A Class edit Part must exist", diagramEditPart);
Assert.assertNotNull("The diagram must be opened", diagramEditPart);
- Assert.assertEquals("The class diagram has to contain two class representation",2, diagramEditPart.getChildren().size());
- IGraphicalEditPart myclassEditPart =(IGraphicalEditPart)diagramEditPart.getChildren().get(0);
- IGraphicalEditPart myOtherclassEditPart =(IGraphicalEditPart)diagramEditPart.getChildren().get(1);
+ Assert.assertEquals("The class diagram has to contain two class representation", 2, diagramEditPart.getChildren().size());
+ IGraphicalEditPart myclassEditPart = (IGraphicalEditPart) diagramEditPart.getChildren().get(0);
+ IGraphicalEditPart myOtherclassEditPart = (IGraphicalEditPart) diagramEditPart.getChildren().get(1);
Assert.assertNotNull("myclassEditPart edit Part must exist", myclassEditPart);
Assert.assertNotNull("myOtherclassEditPart edit Part must exist", myOtherclassEditPart);
ElementTypeConfigurationTypeRegistry.getInstance();
- final IElementType elementType_Dependency=ElementTypeRegistry.getInstance().getType(NEW_DEPENDENCY_ELEMENTTYPE_ID);
-
+ final IElementType elementType_Dependency = ElementTypeRegistry.getInstance().getType(NEW_DEPENDENCY_ELEMENTTYPE_ID);
+
Command command = myOtherclassEditPart.getCommand(createConnectionViewRequest(elementType_Dependency, myclassEditPart, myOtherclassEditPart, diagramEditPart));
assertNotNull("The command to create link must be not null", command);
assertTrue("The command to create link must be executable", command.canExecute() == true);
@@ -113,15 +115,15 @@ public class ExpansionAddLink extends AbstractEditorTest{
assertTrue("The edge must be created", (diagramEditPart.getDiagramView()).getEdges().size() == 1);
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart linkEditPart = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) diagramEditPart.getConnections().get(0);
Assert.assertNotNull("linkEditPart edit Part must exist", linkEditPart);
- Assert.assertEquals("The link must have the type "+DEPENDENCY_HINT,DEPENDENCY_HINT, linkEditPart.getNotationView().getType());
+ Assert.assertEquals("The link must have the type " + DEPENDENCY_HINT, DEPENDENCY_HINT, linkEditPart.getNotationView().getType());
} catch (Exception e) {
e.printStackTrace();
}
}
-
- public CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, DiagramEditPart diagramEditPart ) {
+
+ public CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, DiagramEditPart diagramEditPart) {
CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, diagramEditPart.getDiagramPreferencesHint());
connectionRequest.setSourceEditPart(null);
connectionRequest.setTargetEditPart(source);
@@ -135,19 +137,21 @@ public class ExpansionAddLink extends AbstractEditorTest{
connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
return connectionRequest;
}
+
protected DiagramExpansionsRegistry loadXMIExpansionModel(String filename) {
- DiagramExpansionsRegistry diagramExpansionsRegistry= DiagramExpansionSingleton.getInstance().getDiagramExpansionRegistry();
+ DiagramExpansionsRegistry diagramExpansionsRegistry = DiagramExpansionSingleton.getInstance().getDiagramExpansionRegistry();
diagramExpansionsRegistry.clear();
- Assert.assertEquals("Size ot the registry must be equals to 0",0,diagramExpansionsRegistry.getDiagramExpansions().size());
- Assert.assertEquals("Size ot the map childreen must be equals to 0",0,diagramExpansionsRegistry.mapChildreen.size());
+ Assert.assertEquals("Size ot the registry must be equals to 0", 0, diagramExpansionsRegistry.getDiagramExpansions().size());
+ Assert.assertEquals("Size ot the map childreen must be equals to 0", 0, diagramExpansionsRegistry.mapChildreen.size());
URI badContextExpansion = URI.createPlatformPluginURI("org.eclipse.papyrus.infra.gmfdiag.common.tests", true);
- badContextExpansion=badContextExpansion.appendSegment("models");
- badContextExpansion=badContextExpansion.appendSegment(filename);
+ badContextExpansion = badContextExpansion.appendSegment("models");
+ badContextExpansion = badContextExpansion.appendSegment(filename);
diagramExpansionsRegistry.loadExpansion(badContextExpansion);
return diagramExpansionsRegistry;
}
+
/**
* @see org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest#getSourcePath()
*

Back to the top