Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2014-03-26 10:45:21 -0400
committerptessier2014-03-26 10:45:21 -0400
commit850c5fa883451b39c333759e86bdb4a0d0809830 (patch)
tree184c6cb2889ab03fcab3c27a773c73f6be16be7b /tests/junit
parentc41ebcc389ab8a385fa337c87e5f0d9cd303065b (diff)
downloadorg.eclipse.papyrus-850c5fa883451b39c333759e86bdb4a0d0809830.tar.gz
org.eclipse.papyrus-850c5fa883451b39c333759e86bdb4a0d0809830.tar.xz
org.eclipse.papyrus-850c5fa883451b39c333759e86bdb4a0d0809830.zip
379150: [ModelExplorer] the model explorer should be covered by JUnit
tests https://bugs.eclipse.org/bugs/show_bug.cgi?id=379150
Diffstat (limited to 'tests/junit')
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java12
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java24
4 files changed, 25 insertions, 17 deletions
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF
index 6c7d418d924..881fb25d355 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
org.eclipse.papyrus.infra.core,
org.eclipse.papyrus.emf.facet.custom.metamodel,
- org.eclipse.papyrus.junit.utils
+ org.eclipse.papyrus.junit.utils,
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.uml.modelexplorer.tests
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
index 60e5533aa5d..9a69d6427f5 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
@@ -66,9 +66,7 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final IStructuredSelection currentSelection = getCurrentSelection();
Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
- if(obj instanceof IAdaptable) {
- obj = ((IAdaptable)obj).getAdapter(EObject.class);
- }
+ obj =org.eclipse.papyrus.infra.emf.utils.EMFHelper.getEObject(obj);
Assert.assertEquals("The function revealSemanticElement seems doesn't work on the root of the model", getRootOfTheModel(), obj);
}
@@ -106,9 +104,7 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final IStructuredSelection currentSelection = getCurrentSelection();
Assert.assertTrue("Only one element should be selected", currentSelection.size() == 1); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
- if(obj instanceof IAdaptable) {
- obj = ((IAdaptable)obj).getAdapter(EObject.class);
- }
+ obj =org.eclipse.papyrus.infra.emf.utils.EMFHelper.getEObject(obj);
Assert.assertTrue("The function revealSemanticElement seems doesn't work with children", obj == current);
}
}
@@ -176,9 +172,7 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final IStructuredSelection currentSelection = getCurrentSelection();
Assert.assertEquals("I don't get the correct selection", 1, currentSelection.size()); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
- if(obj instanceof IAdaptable) {
- obj = ((IAdaptable)obj).getAdapter(EObject.class);
- }
+ obj =org.eclipse.papyrus.infra.emf.utils.EMFHelper.getEObject(obj);
Assert.assertEquals("The function revealSemanticElement seems doesn't work with importedPackage", current, obj);
}
}
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF
index 0a4f5386d5f..b3882c9fb0b 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF
@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.junit.utils,
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0",
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.0.0",
- org.eclipse.papyrus.emf.facet.util.core;bundle-version="1.0.0"
+ org.eclipse.papyrus.emf.facet.util.core;bundle-version="1.0.0",
+ org.eclipse.papyrus.emf.facet.custom.core
Export-Package: org.eclipse.papyrus.views.modelexplorer.tests
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
index 9473368cac8..27ae25a52cb 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.views.modelexplorer.tests;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.commands.Command;
@@ -35,6 +36,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.TreeElement;
import org.eclipse.papyrus.emf.facet.util.core.internal.exported.FileUtils;
import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
@@ -167,7 +169,7 @@ public abstract class AbstractHandlerTest {
setResult(activePart);
}
});
-
+
Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
}
@@ -191,9 +193,8 @@ public abstract class AbstractHandlerTest {
IStructuredSelection currentSelection = (IStructuredSelection)selectionService.getSelection();
Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
- if(obj instanceof IAdaptable) {
- obj = ((IAdaptable)obj).getAdapter(EObject.class);
- }
+
+ obj = EMFHelper.getEObject(obj);
Assert.assertSame("the current selected element is not the wanted element", elementToSelect, obj); //$NON-NLS-1$
}
@@ -296,8 +297,19 @@ public abstract class AbstractHandlerTest {
// store the root of the model
Object[] visibleElement = commonViewer.getVisibleExpandedElements();
- modelRoot = EMFHelper.getEObject(visibleElement[0]);
-
+ modelRoot = EMFHelper.getEObject(visibleElement[0]);
+
+ List<Customization> appliedCustomizations=org.eclipse.papyrus.views.modelexplorer.Activator.getDefault().getCustomizationManager().getManagedCustomizations();
+ Customization SimpleUML=null;
+ Iterator<?>iter=appliedCustomizations.iterator();
+ while(iter.hasNext()) {
+ Customization custo = (Customization)iter.next();
+ if( custo.getName().equals("SimpleUML")){
+ SimpleUML=custo;
+ }
+ }
+ org.junit.Assert.assertNotNull("Custom SimpleUML not found", SimpleUML);
+ org.eclipse.papyrus.views.modelexplorer.Activator.getDefault().getCustomizationManager().getManagedCustomizations().add(0, SimpleUML);
setStatus(Status.OK_STATUS);
}
});

Back to the top