From af956e04a9cd7d1349aa8fadacac6bff0cf80838 Mon Sep 17 00:00:00 2001 From: ytanguy Date: Wed, 15 Jun 2011 12:56:51 +0000 Subject: NEW - bug 348832: [Element Edit Service] JUnit tests the Element Edit Service https://bugs.eclipse.org/bugs/show_bug.cgi?id=348832 --- .../registry/TestElementTypeRegistryContent.java | 66 +++++++++++++++------- 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java index 67a54f8bbb9..c43bd68b5a5 100644 --- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java +++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/src/org/eclipse/papyrus/sysml/service/types/tests/registry/TestElementTypeRegistryContent.java @@ -8,18 +8,18 @@ import java.util.Iterator; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager; -import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; import org.eclipse.gmf.runtime.emf.type.core.IClientContext; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils; +import org.eclipse.papyrus.service.edit.service.IElementEditServiceProvider; import org.eclipse.papyrus.sysml.allocations.AllocationsPackage; import org.eclipse.papyrus.sysml.blocks.BlocksPackage; import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage; import org.eclipse.papyrus.sysml.modelelements.ModelelementsPackage; import org.eclipse.papyrus.sysml.portandflows.PortandflowsPackage; import org.eclipse.papyrus.sysml.requirements.RequirementsPackage; -import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; import org.junit.Test; /** @@ -185,26 +185,50 @@ public class TestElementTypeRegistryContent { fail("Papyrus IClientContext could not be found."); } - IElementType associationBaseElementType = ElementTypeRegistry.getInstance().getElementType(UMLPackage.eINSTANCE.getAssociation(), context); - assertTrue("Incorrect id for base Association element type ("+associationBaseElementType.getId()+")", associationBaseElementType.getId().equals("org.eclipse.papyrus.uml.AssociationBase")); + IElementEditServiceProvider service = ElementEditServiceUtils.getEditServiceProvider(); - IElementType associationElementType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.sysml.Association"); - assertTrue("No ISpecializationType found for SysML Association in Papyrus context", ElementEditServiceUtils.getEditServiceProvider().isKnownElementType("org.eclipse.papyrus.sysml.Association")); - assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ associationElementType.getId() +")", associationElementType instanceof ISpecializationType); - ISpecializationType associationSpecializationType = (ISpecializationType) associationElementType; - assertTrue("Incorrect specialization type hierarchy for "+ associationElementType.getId(), associationSpecializationType.isSpecializationOf(associationBaseElementType)); + assertTrue("No ISpecializationType found for SysML Association in Papyrus context", service.isKnownElementType("org.eclipse.papyrus.sysml.Association")); + + assertTrue("Incorrect constant initialization for SysML Association", SysMLElementTypes.ASSOCIATION != null); + assertTrue("Incorrect constant initialization for SysML AssociationComposite", SysMLElementTypes.ASSOCIATION_COMPOSITE != null); + assertTrue("Incorrect constant initialization for SysML AssociationCompositeDirected", SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED != null); + assertTrue("Incorrect constant initialization for SysML AssociationNone", SysMLElementTypes.ASSOCIATION_NONE != null); + assertTrue("Incorrect constant initialization for SysML AssociationNoneDirected", SysMLElementTypes.ASSOCIATION_NONE_DIRECTED != null); + assertTrue("Incorrect constant initialization for SysML AssociationShared", SysMLElementTypes.ASSOCIATION_SHARED != null); + assertTrue("Incorrect constant initialization for SysML AssociationSharedDirected", SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED != null); + + assertTrue("No ISpecializationType found for SysML Association in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION.getId())); + assertTrue("No ISpecializationType found for SysML AssociationComposite in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_COMPOSITE.getId())); + assertTrue("No ISpecializationType found for SysML AssociationCompositeDirected in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.getId())); + assertTrue("No ISpecializationType found for SysML AssociationNone in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_NONE.getId())); + assertTrue("No ISpecializationType found for SysML AssociationNoneDirected in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.getId())); + assertTrue("No ISpecializationType found for SysML AssociationShared in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_SHARED.getId())); + assertTrue("No ISpecializationType found for SysML AssociationSharedDirected in Papyrus context", service.isKnownElementType(SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.getId())); + + assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION.getId() +")", SysMLElementTypes.ASSOCIATION instanceof ISpecializationType); + assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE.getId() +")", SysMLElementTypes.ASSOCIATION_COMPOSITE instanceof ISpecializationType); + assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.getId() +")", SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED instanceof ISpecializationType); + assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_NONE.getId() +")", SysMLElementTypes.ASSOCIATION_NONE instanceof ISpecializationType); + assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.getId() +")", SysMLElementTypes.ASSOCIATION_NONE_DIRECTED instanceof ISpecializationType); + assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_SHARED.getId() +")", SysMLElementTypes.ASSOCIATION_SHARED instanceof ISpecializationType); + assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.getId() +")", SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED instanceof ISpecializationType); + + ISpecializationType association = (ISpecializationType) SysMLElementTypes.ASSOCIATION; + ISpecializationType associationComposite = (ISpecializationType) SysMLElementTypes.ASSOCIATION_COMPOSITE; + ISpecializationType associationCompositeDirected = (ISpecializationType) SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED; + ISpecializationType associationNone = (ISpecializationType) SysMLElementTypes.ASSOCIATION_NONE; + ISpecializationType associationNoneDirected = (ISpecializationType) SysMLElementTypes.ASSOCIATION_NONE_DIRECTED; + ISpecializationType associationShared = (ISpecializationType) SysMLElementTypes.ASSOCIATION_SHARED; + ISpecializationType associationSharedDirected = (ISpecializationType) SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED; + + assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION.getId(), association.isSpecializationOf(UMLElementTypes.ASSOCIATION_BASE)); + assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE.getId(), associationComposite.isSpecializationOf(association)); + assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED.getId(), associationCompositeDirected.isSpecializationOf(association)); + assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_NONE.getId(), associationNone.isSpecializationOf(association)); + assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_NONE_DIRECTED.getId(), associationNoneDirected.isSpecializationOf(association)); + assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_SHARED.getId(), associationShared.isSpecializationOf(association)); + assertTrue("Incorrect specialization type hierarchy for "+ SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED.getId(), associationSharedDirected.isSpecializationOf(association)); -// IElementType associationNoneElementType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.sysml.AssociationNone"); -// assertTrue("No ISpecializationType found for SysML Association in Papyrus context", ElementEditServiceUtils.getEditServiceProvider().isKnownElementType("org.eclipse.papyrus.sysml.AssociationNone")); -// assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ associationElementType.getId() +")", associationNoneElementType instanceof ISpecializationType); -// ISpecializationType associationSpecializationType = (ISpecializationType) associationElementType; -// assertTrue("Incorrect specialization type hierarchy for "+ associationElementType.getId(), associationSpecializationType.isSpecializationOf(associationBaseElementType)); -// -// IElementType associationElementType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.sysml.Association"); -// assertTrue("No ISpecializationType found for SysML Association in Papyrus context", ElementEditServiceUtils.getEditServiceProvider().isKnownElementType("org.eclipse.papyrus.sysml.Association")); -// assertTrue("Incorrect kind of ElementType (ISpecializationType expected for "+ associationElementType.getId() +")", associationElementType instanceof ISpecializationType); -// ISpecializationType associationSpecializationType = (ISpecializationType) associationElementType; -// assertTrue("Incorrect specialization type hierarchy for "+ associationElementType.getId(), associationSpecializationType.isSpecializationOf(associationBaseElementType)); } } -- cgit v1.2.1