Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2015-03-20 14:22:26 +0000
committercbrun2015-04-17 16:12:48 +0000
commit1e7e6a56854a7a5ffb813d83c945ca46a15254c5 (patch)
treea8e651d7025ccf0af7a8d462d265f492e4254ad8
parent7ca9001b6977d26829e37e539f8ecf23133e7b5d (diff)
downloadorg.eclipse.sirius-1e7e6a56854a7a5ffb813d83c945ca46a15254c5.tar.gz
org.eclipse.sirius-1e7e6a56854a7a5ffb813d83c945ca46a15254c5.tar.xz
org.eclipse.sirius-1e7e6a56854a7a5ffb813d83c945ca46a15254c5.zip
[462481] Add Tests for the VariableType infrastructure
Bug: 462481 Change-Id: I87e85312c28c7df098f0894ca2b902b2401e149f Signed-off-by: Cedric Brun <cedric.brun@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign358
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMVariableTypesValidationTest.java258
3 files changed, 618 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign
new file mode 100644
index 0000000000..40610ac87a
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign
@@ -0,0 +1,358 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:validation="http://www.eclipse.org/sirius/description/validation/1.1.0" name="vsmtypes" version="10.0.0.201411061000">
+ <ownedViewpoints name="VSMTypes">
+ <ownedRepresentations xsi:type="description_1:DiagramDescription" name="SelfTypeInference" domainClass="interactions.Model">
+ <metamodel href="http://www.eclipse.org/sirius/sample/interactions#/"/>
+ <validationSet name="Interactions Rules">
+ <ownedRules xsi:type="validation:ViewValidationRule" message="feature:nonExistent" targets="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']">
+ <audits auditExpression="feature:target"/>
+ <audits auditExpression="feature:nonExistent"/>
+ <fixes name="Fix">
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nonExistent"/>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:target"/>
+ </firstModelOperations>
+ </initialOperation>
+ </fixes>
+ </ownedRules>
+ <ownedRules xsi:type="validation:SemanticValidationRule" targetClass="interactions.State">
+ <audits auditExpression="feature:start"/>
+ <audits auditExpression="feature:nonExistent"/>
+ <fixes name="fix the validation">
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:start"/>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nonExistent"/>
+ </firstModelOperations>
+ </initialOperation>
+ </fixes>
+ </ownedRules>
+ </validationSet>
+ <defaultLayer name="Default">
+ <nodeMappings name="ParticipantNode" labelDirectEdit="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='MultipleTypes']" domainClass="interactions.Participant">
+ <style xsi:type="style:BundledImageDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ </style>
+ <conditionnalStyles predicateExpression="feature:nonExistent">
+ <style xsi:type="style:DotDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </conditionnalStyles>
+ </nodeMappings>
+ <nodeMappings name="InteractionNode" labelDirectEdit="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='MultipleTypes']" domainClass="interactions.Interaction">
+ <style xsi:type="style:LozengeNodeDescription" resizeKind="NSEW">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ </style>
+ </nodeMappings>
+ <edgeMappings name="ParticipantNode to InteractionNode through Message" sourceMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']" targetMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='InteractionNode']" targetFinderExpression="feature:nonExistent" sourceFinderExpression="feature:nonExistent" domainClass="interactions.Message" useDomainElement="true">
+ <style sizeComputationExpression="2">
+ <strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ <centerLabelStyleDescription>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ </centerLabelStyleDescription>
+ </style>
+ </edgeMappings>
+ <edgeMappings name="Dupplicate ParticipantNode to InteractionNode through Message" sourceMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']" targetMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='InteractionNode']" targetFinderExpression="feature:nonExistent" sourceFinderExpression="feature:nonExistent" domainClass="interactions.Message" useDomainElement="true">
+ <style sizeComputationExpression="2">
+ <strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ <centerLabelStyleDescription>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ </centerLabelStyleDescription>
+ </style>
+ </edgeMappings>
+ <edgeMappings name="(Participant/Interaction)Container to (Participant/Interaction)Container through Message" sourceMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='ParticipantContainer'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='InteractionContainer']" targetMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='InteractionContainer'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='ParticipantContainer']" targetFinderExpression="feature:nonExistent" sourceFinderExpression="feature:nonExistent" domainClass="interactions.Message" useDomainElement="true">
+ <style sizeComputationExpression="2">
+ <strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
+ <centerLabelStyleDescription>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ </centerLabelStyleDescription>
+ </style>
+ </edgeMappings>
+ <containerMappings name="ParticipantContainer" labelDirectEdit="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@subSections[name='Ignored']/@ownedTools[name='ElementType']" domainClass="interactions.Participant">
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ <conditionnalStyles predicateExpression="feature:nonExistent">
+ <style xsi:type="style:ShapeContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </conditionnalStyles>
+ </containerMappings>
+ <containerMappings name="InteractionContainer" domainClass="interactions.Interaction">
+ <style xsi:type="style:WorkspaceImageDescription" workspacePath="/org.eclipse.emf.ecore.edit/icons/full/obj16/EClass.gif">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ </style>
+ </containerMappings>
+ <containerMappings name="StateContainer" labelDirectEdit="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='MultipleTypes']" domainClass="interactions.State">
+ <style xsi:type="style:ShapeContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <toolSections name="ShouldBeValid">
+ <ownedTools xsi:type="tool_1:NodeCreationDescription" name="Check Node variables types are infered" nodeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='InteractionNode'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:container">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:ownedInteractions"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:containerView">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:target"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:ContainerCreationDescription" name="Check variables types with multiple self types" containerMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='InteractionContainer'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='ParticipantContainer']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:container">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:ownedInteractions"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:NodeCreationDescription" name="Only Participant Mapping" nodeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:EdgeCreationDescription" name="Domain Participant/InteractionContainer to Interaction/Participant Container" edgeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@edgeMappings[name='(Participant%2FInteraction)Container%20to%20(Participant%2FInteraction)Container%20through%20Message']">
+ <sourceVariable name="source"/>
+ <targetVariable name="target"/>
+ <sourceViewVariable name="sourceView"/>
+ <targetViewVariable name="targetView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:source">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:target">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:sendingEnd"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:DirectEditLabel" name="MultipleTypes">
+ <mask mask="{0}"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/>
+ <subModelOperations xsi:type="tool:CreateInstance" typeName="interactions.Message" referenceName="nonExistent" variableName="createdMessage">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:sendingEnd">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:eContainer">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:createdMessage">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:sendingEnd"/>
+ </subModelOperations>
+ </subModelOperations>
+ </subModelOperations>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:CreateInstance" typeName="interactions.Participant" referenceName="nonExistent">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/>
+ <subModelOperations xsi:type="tool:CreateInstance" typeName="interactions.Execution" referenceName="nonExistent">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:start"/>
+ </subModelOperations>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:CreateInstance" typeName="ecore.EClass" referenceName="nonExistent">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:abstract"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:EdgeCreationDescription" name="Domain Participant/InteractionContainer to Interaction/Participant Container Other" edgeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@edgeMappings[name='(Participant%2FInteraction)Container%20to%20(Participant%2FInteraction)Container%20through%20Message']">
+ <sourceVariable name="source"/>
+ <targetVariable name="target"/>
+ <sourceViewVariable name="sourceView"/>
+ <targetViewVariable name="targetView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:sendingEnd"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <subSections name="Ignored">
+ <ownedTools xsi:type="tool_1:DirectEditLabel" name="ElementType">
+ <mask mask="{0}"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:arg0">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:element">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/>
+ </subModelOperations>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:EdgeCreationDescription" name="Domain ParticipantNode to Interaction Node" edgeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@edgeMappings[name='ParticipantNode%20to%20InteractionNode%20through%20Message']">
+ <sourceVariable name="source"/>
+ <targetVariable name="target"/>
+ <sourceViewVariable name="sourceView"/>
+ <targetViewVariable name="targetView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:source">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:target">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:participants"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:sendingEnd"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:targetView">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:resizeKind"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:sourceView">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:resizeKind"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:EdgeCreationDescription" name="Domain ParticipantNode to Interaction Node two Edge Mappings" edgeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@edgeMappings[name='ParticipantNode%20to%20InteractionNode%20through%20Message'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@edgeMappings[name='Dupplicate%20ParticipantNode%20to%20InteractionNode%20through%20Message']">
+ <sourceVariable name="source"/>
+ <targetVariable name="target"/>
+ <sourceViewVariable name="sourceView"/>
+ <targetViewVariable name="targetView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:source">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:target">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:participants"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:sendingEnd"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:targetView">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:resizeKind"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:sourceView">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:resizeKind"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:NodeCreationDescription" name="CreateViews" nodeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='InteractionNode'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool_1:CreateView" mapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']" containerViewExpression="var:containerView" variableName="createdNode">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:resizeKind"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool_1:CreateView" mapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='ParticipantContainer']" containerViewExpression="var:containerView" variableName="createdContainer">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:childrenPresentation"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ </subSections>
+ </toolSections>
+ <toolSections name="ShouldBeInvalid">
+ <ownedTools xsi:type="tool_1:NodeCreationDescription" name="Goto self.nonExistent" nodeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='InteractionNode'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nonExistent"/>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:ContainerCreationDescription" name="Container Goto self.nonExistent" containerMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='InteractionContainer'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='ParticipantContainer']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nonExistent"/>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:EdgeCreationDescription" name="Domain Participant/InteractionContainer to Interaction/Participant Container" edgeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@edgeMappings[name='(Participant%2FInteraction)Container%20to%20(Participant%2FInteraction)Container%20through%20Message']">
+ <sourceVariable name="source"/>
+ <targetVariable name="target"/>
+ <sourceViewVariable name="sourceView"/>
+ <targetViewVariable name="targetView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:source">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:target">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:participants"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:EdgeCreationDescription" name="Domain Participant/InteractionContainer to Interaction/Participant Container With Extra Mapping" edgeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@edgeMappings[name='(Participant%2FInteraction)Container%20to%20(Participant%2FInteraction)Container%20through%20Message']" extraSourceMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='StateContainer']" extraTargetMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='StateContainer']">
+ <sourceVariable name="source"/>
+ <targetVariable name="target"/>
+ <sourceViewVariable name="sourceView"/>
+ <targetViewVariable name="targetView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:sendingEnd"/>
+ </subModelOperations>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <subSections name="Ignored">
+ <ownedTools xsi:type="tool_1:NodeCreationDescription" name="Goto container.nonExistent" nodeMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='InteractionNode'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@nodeMappings[name='ParticipantNode']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:container">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nonExistent"/>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ <ownedTools xsi:type="tool_1:ContainerCreationDescription" name="Container Goto container.nonExistent" containerMappings="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='InteractionContainer'] //@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@containerMappings[name='ParticipantContainer']">
+ <variable name="container"/>
+ <viewVariable name="containerView"/>
+ <initialOperation>
+ <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:container">
+ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nonExistent"/>
+ </firstModelOperations>
+ </initialOperation>
+ </ownedTools>
+ </subSections>
+ </toolSections>
+ </defaultLayer>
+ </ownedRepresentations>
+ </ownedViewpoints>
+</description:Group>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
index cb427abb01..935c02d5be 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramPluginsTests.java
@@ -225,6 +225,7 @@ import org.eclipse.sirius.tests.unit.diagram.tools.palette.PaletteUpdateDoesNotD
import org.eclipse.sirius.tests.unit.diagram.tools.palette.PaletteUpdateWithoutInvalidThreadAccessTest;
import org.eclipse.sirius.tests.unit.diagram.views.session.ModelContentTest;
import org.eclipse.sirius.tests.unit.diagram.vsm.VSMValidationTest;
+import org.eclipse.sirius.tests.unit.diagram.vsm.VSMVariableTypesValidationTest;
import org.eclipse.sirius.tests.unit.diagram.vsm.VSMWithCustomizationValidationTests;
import org.eclipse.sirius.tests.unit.perf.diagram.refresh.connections.DCompartmentConnectionRefreshMgrTest;
@@ -488,6 +489,7 @@ public class AllDiagramPluginsTests {
// VSM
suite.addTestSuite(VSMValidationTest.class);
suite.addTestSuite(VSMWithCustomizationValidationTests.class);
+ suite.addTest(new JUnit4TestAdapter(VSMVariableTypesValidationTest.class));
suite.addTestSuite(DiagramCustomizationTest.class);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMVariableTypesValidationTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMVariableTypesValidationTest.java
new file mode 100644
index 0000000000..b9ef525103
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMVariableTypesValidationTest.java
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.unit.diagram.vsm;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.sirius.common.tools.api.interpreter.CompoundInterpreter;
+import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
+import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterContext;
+import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterStatus;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.sirius.tools.api.interpreter.context.SiriusInterpreterContextFactory;
+import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
+import org.eclipse.sirius.viewpoint.description.Group;
+import org.eclipse.sirius.viewpoint.description.Viewpoint;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+/**
+ * Test checking the variable types are correctly infered when validating a VSM.
+ *
+ * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
+ */
+@RunWith(value = Parameterized.class)
+public class VSMVariableTypesValidationTest {
+ /**
+ * This VSM is conform to some specific conventions to make it easy to test
+ * the type analysis of variables in a VSM.
+ *
+ * Types are checked by having a ChangeContext operation with
+ * feature:someThing where someThing is specific to the expected type.
+ *
+ * feature:nonExistent is used through the VSM for expressions we expect to
+ * fail.
+ *
+ * There are two sections of tools : "ShouldBeValid" is supposed to have no
+ * validation error whatsoever "ShouldBeInvalid" is supposed to have *every
+ * feature:* expression in it failing with a validation error.
+ *
+ */
+ private static final String ORG_ECLIPSE_SIRIUS_TESTS_JUNIT_DATA_UNIT_VSM_VALIDATE_VARIABLE_TYPES_ODESIGN = "/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign";
+
+ private InterpretedExpression underTest;
+
+ public VSMVariableTypesValidationTest(InterpretedExpression expression) {
+ this.underTest = expression;
+ }
+
+ @Parameters(name = "org.eclipse.sirius.tests.unit.diagram.vsm.VSMVariableTypesValidationTest.{index}: ({0})")
+ public static Collection<Object[]> data() throws IOException {
+ URI uri = URI.createPlatformPluginURI(ORG_ECLIPSE_SIRIUS_TESTS_JUNIT_DATA_UNIT_VSM_VALIDATE_VARIABLE_TYPES_ODESIGN, true);
+
+ List<Object[]> parameters = Lists.newArrayList();
+ Group group = loadVSM(uri);
+ if (group != null) {
+ for (Viewpoint vp : group.getOwnedViewpoints()) {
+ Iterator<EObject> it = vp.eAllContents();
+ while (it.hasNext()) {
+ EObject underTest = it.next();
+ for (EAttribute attr : underTest.eClass().getEAllAttributes()) {
+ if (attr.getEType() == DescriptionPackage.eINSTANCE.getInterpretedExpression()) {
+ Object expr = underTest.eGet(attr);
+ if (expr instanceof String && ((String) expr).length() > 0) {
+ if (((String) expr).startsWith("feature:")) {
+ parameters.add(new Object[] { new InterpretedExpression((String) expr, underTest, attr) });
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+ return parameters;
+ }
+
+ private static Group loadVSM(URI uri) {
+ ResourceSet set = new ResourceSetImpl();
+ /*
+ * we need an ECrossReferenceAdapter as some of the VSM implementation
+ * classes are needing it.
+ */
+ ECrossReferenceAdapter crossReferencer = new ECrossReferenceAdapter();
+ set.eAdapters().add(crossReferencer);
+ Resource res = set.getResource(uri, true);
+ for (EObject root : res.getContents()) {
+ if (root instanceof Group) {
+ return (Group) root;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This test triggers the validation on the current expression and checks
+ * the expectations regarding the reported statuses (there is an error, or
+ * not) are fulfilled. Such expectations are encoded by the use of
+ * 'nonExistent' in the expression when an error should be triggered or the
+ * fact that the englobing tool is in a section named 'ShouldBeInvalid'
+ * Otherwise we expects to have no validation error.
+ *
+ * Any expression which is a direct or indirect children of a tool section
+ * named 'Ignored' is not considered by this test.
+ */
+ @Test
+ public void matchesExpectationsRegardingValidation() {
+ String expression = this.underTest.getExpression();
+ IInterpreter interpreterForExpression = CompoundInterpreter.INSTANCE.getInterpreterForExpression(expression);
+
+ Collection<IInterpreterStatus> errors = Sets.newLinkedHashSet();
+ if (interpreterForExpression.supportsValidation()) {
+ IInterpreterContext context = SiriusInterpreterContextFactory.createInterpreterContext(this.underTest.getDeclaration(), this.underTest.getFeature());
+ errors = interpreterForExpression.validateExpression(context, expression);
+ boolean useNonExistantFeature = expression.contains("nonExistent");
+ if (!isInToolSection(underTest.getDeclaration(), "Ignored")) {
+ if (useNonExistantFeature && errors.size() == 0) {
+ /*
+ * we should have an error
+ */
+ fail("We expected at least an error for : " + this.underTest.toString());
+ } else {
+ /*
+ * we have errors
+ */
+ if (isInToolSection(underTest.getDeclaration(), "ShouldBeInvalid") && !useNonExistantFeature) {
+ /*
+ * its ok to have an error here.
+ */
+ } else if (!useNonExistantFeature && errors.size() > 0) {
+ String message = underTest.toString() + "triggers unexpected errors \n" + Joiner.on('\n').join(Iterables.transform(errors, new Function<IInterpreterStatus, String>() {
+
+ @Override
+ public String apply(IInterpreterStatus input) {
+ return input.getSeverity() + " : " + input.getMessage();
+ }
+ }));
+
+ fail(message);
+ }
+
+ }
+ }
+ }
+
+ }
+
+ private boolean isInToolSection(EObject declaration, String name) {
+ EObject cur = declaration;
+ while (cur != null) {
+ if (cur instanceof ToolSection) {
+ if (name.equals(((ToolSection) cur).getName())) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+ cur = cur.eContainer();
+
+ }
+ return false;
+ }
+
+}
+
+class InterpretedExpression {
+
+ private String expression;
+
+ private EObject declaration;
+
+ private EAttribute feature;
+
+ public InterpretedExpression(String expression, EObject declaration, EAttribute feature) {
+ super();
+ this.expression = expression;
+ this.declaration = declaration;
+ this.feature = feature;
+ }
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public EObject getDeclaration() {
+ return declaration;
+ }
+
+ public EAttribute getFeature() {
+ return feature;
+ }
+
+ @Override
+ public String toString() {
+ return getFeature().getName() + " : " + expression + " in " + qualifiedName(getDeclaration());
+ }
+
+ private String qualifiedName(EObject declaration) {
+ List<String> segments = Lists.newArrayList();
+
+ EObject cur = declaration;
+ while (cur != null) {
+
+ Object label = getIfThere(cur, "label");
+ if (label instanceof String) {
+ segments.add((String) label);
+ } else {
+ Object name = getIfThere(cur, "name");
+ if (name instanceof String) {
+ segments.add((String) name);
+ } else {
+ segments.add(cur.eClass().getName());
+ }
+
+ }
+ cur = cur.eContainer();
+ }
+ return Joiner.on(':').join(Lists.reverse(segments));
+ }
+
+ private Object getIfThere(EObject cur, String name) {
+ EStructuralFeature feature = cur.eClass().getEStructuralFeature(name);
+ if (feature != null) {
+ return cur.eGet(feature);
+ }
+ return null;
+ }
+
+}

Back to the top