diff options
author | Ansgar Radermacher | 2017-01-19 12:09:14 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2017-01-20 12:56:15 +0000 |
commit | bd504dc1f5be8278258a9d3b816f05e488fe1326 (patch) | |
tree | 1793c5891debee1aac52b208c10a839d3a722fb4 | |
parent | 1b31148b3b8a2c9f5a1327203a7561e313eae5b7 (diff) | |
download | org.eclipse.papyrus-rt-bd504dc1f5be8278258a9d3b816f05e488fe1326.tar.gz org.eclipse.papyrus-rt-bd504dc1f5be8278258a9d3b816f05e488fe1326.tar.xz org.eclipse.papyrus-rt-bd504dc1f5be8278258a9d3b816f05e488fe1326.zip |
Bug 477811 - [Tooling] Combine the port and protocol message selection into one combined create trigger dialog
- Add a test for ProtocolMessageProvider:
- check whether AnyReceiveEvent is available
- check whether Inherited messages are found (and in right order)
- check whether a double port selection results in finding the common subset
- check whether conjugation is taken into account
- Remove deprecated code in ProtocolUtils
Change-Id: I30d5213d43e0cdfd8652bc45fb711bab1a42a5a3
5 files changed, 366 insertions, 41 deletions
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/ProtocolUtils.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/ProtocolUtils.java index e0b475ce4..513badb16 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/ProtocolUtils.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/ProtocolUtils.java @@ -21,8 +21,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.emf.transaction.util.TransactionUtil; @@ -138,25 +136,6 @@ public class ProtocolUtils { } /** - * Get all protocols that are associated with a protocol, in particular - * "inherited" protocols. Currently, inheritance is not supported, but - * all protocols implicitly "inherit" a base protocol. - * - * @param protocol - * @return all protocols. - */ - @Deprecated - public static EList<Package> getAllProtocols(Package protocol) { - EList<Package> allProtocols = new BasicEList<>(); - Collaboration baseProtocol = getBaseProtocol(protocol); - if ((baseProtocol != null) && (protocol != baseProtocol)) { - allProtocols.add(getProtocolContainer(baseProtocol)); - } - allProtocols.add(protocol); - return allProtocols; - } - - /** * Get all protocols that are associated with a protocol: baseProtocols and * inherited protocols. The following order is applied: base protocols first, * root super protocol, then more specific protocols @@ -186,26 +165,6 @@ public class ProtocolUtils { * a candidate for a protocol that may be common * @return true, iff the protocol is a common protocol */ - @Deprecated - public static boolean isCommonProtocol(EList<Package> protocolSet, Package protocolCandidate) { - for (Package protocol : protocolSet) { - if (!ProtocolUtils.getAllProtocols(protocol).contains(protocolCandidate)) { - return false; - } - } - return true; - } - - - /** - * Check whether a given protocol candidate is a common protocol in a set of protocols (including inherited protocols) - * - * @param protocolSet - * a list of protocols for which we examine - * @param protocolCandidate - * a candidate for a protocol that may be common - * @return true, iff the protocol is a common protocol - */ public static boolean isCommonProtocol(Collection<UMLRTProtocol> protocolSet, UMLRTProtocol protocolCandidate) { for (UMLRTProtocol protocol : protocolSet) { if (!ProtocolUtils.getAllProtocols(protocol).contains(protocolCandidate)) { diff --git a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.di b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.di new file mode 100644 index 000000000..bf9abab34 --- /dev/null +++ b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.notation b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.notation new file mode 100644 index 000000000..bf9abab34 --- /dev/null +++ b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.notation @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.uml b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.uml new file mode 100644 index 000000000..71c8fa00e --- /dev/null +++ b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/dialogs/TriggerCreationTest.uml @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:UMLRTStateMachines="http://www.eclipse.org/papyrus/umlrt/statemachine" xmlns:UMLRealTime="http://www.eclipse.org/papyrus/umlrt" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_pLIQANjXEeac-OeU7l5TJQ" name="RootElement"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__L4KYNjXEeac-OeU7l5TJQ" source="http://www.eclipse.org/papyrus-rt/language/1.0.0"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__L5YgNjXEeac-OeU7l5TJQ" key="language" value="umlrt-cpp"/> + </eAnnotations> + <packagedElement xmi:type="uml:Class" xmi:id="_A_KF4NjYEeac-OeU7l5TJQ" name="Capsule1" classifierBehavior="_TyGAcNjYEeac-OeU7l5TJQ" isActive="true"> + <ownedAttribute xmi:type="uml:Port" xmi:id="_HW6AMNjaEeac-OeU7l5TJQ" name="base" type="_Ba_bYNjaEeac-OeU7l5TJQ" isOrdered="true" aggregation="composite" isBehavior="true"/> + <ownedAttribute xmi:type="uml:Port" xmi:id="_6E_hYNjdEeac-OeU7l5TJQ" name="sub" type="_zowdwNjdEeac-OeU7l5TJQ" isOrdered="true" aggregation="composite" isBehavior="true"/> + <ownedAttribute xmi:type="uml:Port" xmi:id="_R0TWcNl6Eeabyf-IzF9zXA" name="subSub" type="_EDFCQNl6Eeabyf-IzF9zXA" isOrdered="true" aggregation="composite" isBehavior="true"/> + <ownedBehavior xmi:type="uml:StateMachine" xmi:id="_TyGAcNjYEeac-OeU7l5TJQ" name="StateMachine" isReentrant="false"> + <region xmi:type="uml:Region" xmi:id="_TyheQNjYEeac-OeU7l5TJQ" name="Region"> + <transition xmi:type="uml:Transition" xmi:id="_TzZoANjYEeac-OeU7l5TJQ" name="Initial" source="_TywHwNjYEeac-OeU7l5TJQ" target="_TzK-gNjYEeac-OeU7l5TJQ"/> + <transition xmi:type="uml:Transition" xmi:id="_WT7EANjYEeac-OeU7l5TJQ" source="_TzK-gNjYEeac-OeU7l5TJQ" target="_VtjAgNjYEeac-OeU7l5TJQ"/> + <subvertex xmi:type="uml:Pseudostate" xmi:id="_TywHwNjYEeac-OeU7l5TJQ"> + <name xsi:nil="true"/> + </subvertex> + <subvertex xmi:type="uml:State" xmi:id="_TzK-gNjYEeac-OeU7l5TJQ" name="State1"/> + <subvertex xmi:type="uml:State" xmi:id="_VtjAgNjYEeac-OeU7l5TJQ" name="State2"/> + </region> + </ownedBehavior> + </packagedElement> + <packagedElement xmi:type="uml:Package" xmi:id="_BbDFwNjaEeac-OeU7l5TJQ" name="Base"> + <packagedElement xmi:type="uml:Collaboration" xmi:id="_Ba_bYNjaEeac-OeU7l5TJQ" name="Base"> + <interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_BbH-QNjaEeac-OeU7l5TJQ" client="_Ba_bYNjaEeac-OeU7l5TJQ" supplier="_BbFiANjaEeac-OeU7l5TJQ" contract="_BbFiANjaEeac-OeU7l5TJQ"/> + <interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_BbQhINjaEeac-OeU7l5TJQ" client="_Ba_bYNjaEeac-OeU7l5TJQ" supplier="_BbOE4djaEeac-OeU7l5TJQ" contract="_BbOE4djaEeac-OeU7l5TJQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Interface" xmi:id="_BbFiANjaEeac-OeU7l5TJQ" name="Base"> + <ownedOperation xmi:type="uml:Operation" xmi:id="_FWxUcNjaEeac-OeU7l5TJQ" name="baseResponse"/> + </packagedElement> + <packagedElement xmi:type="uml:Interface" xmi:id="_BbH-QdjaEeac-OeU7l5TJQ" name="Base~"> + <ownedOperation xmi:type="uml:Operation" xmi:id="_Dmx9gNjaEeac-OeU7l5TJQ" name="baseRequest"/> + </packagedElement> + <packagedElement xmi:type="uml:Usage" xmi:id="_BbKagNjaEeac-OeU7l5TJQ" client="_Ba_bYNjaEeac-OeU7l5TJQ" supplier="_BbH-QdjaEeac-OeU7l5TJQ"/> + <packagedElement xmi:type="uml:AnyReceiveEvent" xmi:id="_BbOE4NjaEeac-OeU7l5TJQ" name="*"/> + <packagedElement xmi:type="uml:Interface" xmi:id="_BbOE4djaEeac-OeU7l5TJQ" name="BaseIO"/> + <packagedElement xmi:type="uml:Usage" xmi:id="_BbbgQNjaEeac-OeU7l5TJQ" client="_Ba_bYNjaEeac-OeU7l5TJQ" supplier="_BbOE4djaEeac-OeU7l5TJQ"/> + <packagedElement xmi:type="uml:CallEvent" xmi:id="_Dm1n4NjaEeac-OeU7l5TJQ" operation="_Dmx9gNjaEeac-OeU7l5TJQ"/> + <packagedElement xmi:type="uml:CallEvent" xmi:id="_FWzwsNjaEeac-OeU7l5TJQ" operation="_FWxUcNjaEeac-OeU7l5TJQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Package" xmi:id="_zoxr4NjdEeac-OeU7l5TJQ" name="Sub"> + <packagedElement xmi:type="uml:Collaboration" xmi:id="_zowdwNjdEeac-OeU7l5TJQ" name="Sub"> + <generalization xmi:type="uml:Generalization" xmi:id="_3u9eINjdEeac-OeU7l5TJQ" general="_Ba_bYNjaEeac-OeU7l5TJQ"/> + <interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_zo3LcNjdEeac-OeU7l5TJQ" client="_zowdwNjdEeac-OeU7l5TJQ" supplier="_zo0IINjdEeac-OeU7l5TJQ" contract="_zo0IINjdEeac-OeU7l5TJQ"/> + <interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_zo7c4NjdEeac-OeU7l5TJQ" client="_zowdwNjdEeac-OeU7l5TJQ" supplier="_zo5nstjdEeac-OeU7l5TJQ" contract="_zo5nstjdEeac-OeU7l5TJQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Interface" xmi:id="_zo0IINjdEeac-OeU7l5TJQ" name="Sub"> + <generalization xmi:type="uml:Generalization" xmi:id="_3u-FMNjdEeac-OeU7l5TJQ" general="_BbFiANjaEeac-OeU7l5TJQ"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_1-_8YNjdEeac-OeU7l5TJQ" name="subResponse"/> + </packagedElement> + <packagedElement xmi:type="uml:Interface" xmi:id="_zo3ygNjdEeac-OeU7l5TJQ" name="Sub~"> + <generalization xmi:type="uml:Generalization" xmi:id="_3vBIgNjdEeac-OeU7l5TJQ" general="_BbH-QdjaEeac-OeU7l5TJQ"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_0ka0wNjdEeac-OeU7l5TJQ" name="subRequest"/> + </packagedElement> + <packagedElement xmi:type="uml:Usage" xmi:id="_zo5nsNjdEeac-OeU7l5TJQ" client="_zowdwNjdEeac-OeU7l5TJQ" supplier="_zo3ygNjdEeac-OeU7l5TJQ"/> + <packagedElement xmi:type="uml:AnyReceiveEvent" xmi:id="_zo5nsdjdEeac-OeU7l5TJQ" name="*"/> + <packagedElement xmi:type="uml:Interface" xmi:id="_zo5nstjdEeac-OeU7l5TJQ" name="SubIO"> + <generalization xmi:type="uml:Generalization" xmi:id="_3vGBANjdEeac-OeU7l5TJQ" general="_BbOE4djaEeac-OeU7l5TJQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Usage" xmi:id="_zo8D8NjdEeac-OeU7l5TJQ" client="_zowdwNjdEeac-OeU7l5TJQ" supplier="_zo5nstjdEeac-OeU7l5TJQ"/> + <packagedElement xmi:type="uml:CallEvent" xmi:id="_0kdRANjdEeac-OeU7l5TJQ" operation="_0ka0wNjdEeac-OeU7l5TJQ"/> + <packagedElement xmi:type="uml:CallEvent" xmi:id="_1_CYoNjdEeac-OeU7l5TJQ" operation="_1-_8YNjdEeac-OeU7l5TJQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Package" xmi:id="_EDpC8Nl6Eeabyf-IzF9zXA" name="SubSub"> + <packagedElement xmi:type="uml:Collaboration" xmi:id="_EDFCQNl6Eeabyf-IzF9zXA" name="SubSub"> + <generalization xmi:type="uml:Generalization" xmi:id="_Ivr7UNl6Eeabyf-IzF9zXA" general="_zowdwNjdEeac-OeU7l5TJQ"/> + <interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_EELOcNl6Eeabyf-IzF9zXA" client="_EDFCQNl6Eeabyf-IzF9zXA" supplier="_EEEgwNl6Eeabyf-IzF9zXA" contract="_EEEgwNl6Eeabyf-IzF9zXA"/> + <interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_EExrYNl6Eeabyf-IzF9zXA" client="_EDFCQNl6Eeabyf-IzF9zXA" supplier="_EErkwNl6Eeabyf-IzF9zXA" contract="_EErkwNl6Eeabyf-IzF9zXA"/> + </packagedElement> + <packagedElement xmi:type="uml:Interface" xmi:id="_EEEgwNl6Eeabyf-IzF9zXA" name="SubSub"> + <generalization xmi:type="uml:Generalization" xmi:id="_IvuXkNl6Eeabyf-IzF9zXA" general="_zo0IINjdEeac-OeU7l5TJQ"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_G3KTcNl6Eeabyf-IzF9zXA" name="subSubResponse"/> + </packagedElement> + <packagedElement xmi:type="uml:Interface" xmi:id="_EESjMNl6Eeabyf-IzF9zXA" name="SubSub~"> + <generalization xmi:type="uml:Generalization" xmi:id="_IwAEYNl6Eeabyf-IzF9zXA" general="_zo3ygNjdEeac-OeU7l5TJQ"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_FdaSQNl6Eeabyf-IzF9zXA" name="subSubRequest"/> + </packagedElement> + <packagedElement xmi:type="uml:Usage" xmi:id="_EEn6YNl6Eeabyf-IzF9zXA" client="_EDFCQNl6Eeabyf-IzF9zXA" supplier="_EESjMNl6Eeabyf-IzF9zXA"/> + <packagedElement xmi:type="uml:AnyReceiveEvent" xmi:id="_EEpIgNl6Eeabyf-IzF9zXA" name="*"/> + <packagedElement xmi:type="uml:Interface" xmi:id="_EErkwNl6Eeabyf-IzF9zXA" name="SubSubIO"> + <generalization xmi:type="uml:Generalization" xmi:id="_IwMRoNl6Eeabyf-IzF9zXA" general="_zo5nstjdEeac-OeU7l5TJQ"/> + </packagedElement> + <packagedElement xmi:type="uml:Usage" xmi:id="_EEzgkNl6Eeabyf-IzF9zXA" client="_EDFCQNl6Eeabyf-IzF9zXA" supplier="_EErkwNl6Eeabyf-IzF9zXA"/> + <packagedElement xmi:type="uml:CallEvent" xmi:id="_FdubUNl6Eeabyf-IzF9zXA" operation="_FdaSQNl6Eeabyf-IzF9zXA"/> + <packagedElement xmi:type="uml:CallEvent" xmi:id="_G3VSkNl6Eeabyf-IzF9zXA" operation="_G3KTcNl6Eeabyf-IzF9zXA"/> + </packagedElement> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_pQLvINjXEeac-OeU7l5TJQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_pQQnoNjXEeac-OeU7l5TJQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/umlrt#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_RT_PROFILE/uml-rt.profile.uml#_1h74oEeVEeO0lv5O1DTHOQ"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_pbQWsNjXEeac-OeU7l5TJQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_pbQ9wNjXEeac-OeU7l5TJQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/umlrt/statemachine#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UML_RT_PROFILE/UMLRealTimeSM-addendum.profile.uml#_KLcn0FDtEeOA4ecmvfqvaw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="__Nt9cNjXEeac-OeU7l5TJQ"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__NukgNjXEeac-OeU7l5TJQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/umlrt/cppproperties#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://UMLRT_CPP/RTCppProperties.profile.uml#_vl5LALs8EeSTjNEQkASznQ"/> + </profileApplication> + </uml:Model> + <UMLRealTime:Capsule xmi:id="_BDX3gNjYEeac-OeU7l5TJQ" base_Class="_A_KF4NjYEeac-OeU7l5TJQ"/> + <UMLRTStateMachines:RTPseudostate xmi:id="_Ty8VANjYEeac-OeU7l5TJQ" base_Pseudostate="_TywHwNjYEeac-OeU7l5TJQ"/> + <UMLRTStateMachines:RTState xmi:id="_TzOo4NjYEeac-OeU7l5TJQ" base_State="_TzK-gNjYEeac-OeU7l5TJQ"/> + <UMLRTStateMachines:RTRegion xmi:id="_TzcrUNjYEeac-OeU7l5TJQ" base_Region="_TyheQNjYEeac-OeU7l5TJQ"/> + <UMLRTStateMachines:RTStateMachine xmi:id="_T0hCUNjYEeac-OeU7l5TJQ" base_StateMachine="_TyGAcNjYEeac-OeU7l5TJQ"/> + <UMLRTStateMachines:RTState xmi:id="_VtlcwNjYEeac-OeU7l5TJQ" base_State="_VtjAgNjYEeac-OeU7l5TJQ"/> + <UMLRealTime:ProtocolContainer xmi:id="_BbET4NjaEeac-OeU7l5TJQ" base_Package="_BbDFwNjaEeac-OeU7l5TJQ"/> + <UMLRealTime:RTMessageSet xmi:id="_BbHXMNjaEeac-OeU7l5TJQ" base_Interface="_BbFiANjaEeac-OeU7l5TJQ"/> + <UMLRealTime:RTMessageSet xmi:id="_BbJMYNjaEeac-OeU7l5TJQ" base_Interface="_BbH-QdjaEeac-OeU7l5TJQ" rtMsgKind="out"/> + <UMLRealTime:RTMessageSet xmi:id="_BbPTANjaEeac-OeU7l5TJQ" base_Interface="_BbOE4djaEeac-OeU7l5TJQ" rtMsgKind="inOut"/> + <UMLRealTime:Protocol xmi:id="_BbcHUNjaEeac-OeU7l5TJQ" base_Collaboration="_Ba_bYNjaEeac-OeU7l5TJQ"/> + <UMLRealTime:RTPort xmi:id="_HW8ccNjaEeac-OeU7l5TJQ" base_Port="_HW6AMNjaEeac-OeU7l5TJQ"/> + <UMLRealTime:ProtocolContainer xmi:id="_zoy6ANjdEeac-OeU7l5TJQ" base_Package="_zoxr4NjdEeac-OeU7l5TJQ"/> + <UMLRealTime:RTMessageSet xmi:id="_zo2kYNjdEeac-OeU7l5TJQ" base_Interface="_zo0IINjdEeac-OeU7l5TJQ"/> + <UMLRealTime:RTMessageSet xmi:id="_zo5AoNjdEeac-OeU7l5TJQ" base_Interface="_zo3ygNjdEeac-OeU7l5TJQ" rtMsgKind="out"/> + <UMLRealTime:RTMessageSet xmi:id="_zo610NjdEeac-OeU7l5TJQ" base_Interface="_zo5nstjdEeac-OeU7l5TJQ" rtMsgKind="inOut"/> + <UMLRealTime:Protocol xmi:id="_zo8D8djdEeac-OeU7l5TJQ" base_Collaboration="_zowdwNjdEeac-OeU7l5TJQ"/> + <UMLRealTime:RTPort xmi:id="_6FB9oNjdEeac-OeU7l5TJQ" base_Port="_6E_hYNjdEeac-OeU7l5TJQ"/> + <UMLRealTime:ProtocolContainer xmi:id="_EDstUNl6Eeabyf-IzF9zXA" base_Package="_EDpC8Nl6Eeabyf-IzF9zXA"/> + <UMLRealTime:RTMessageSet xmi:id="_EEIyMNl6Eeabyf-IzF9zXA" base_Interface="_EEEgwNl6Eeabyf-IzF9zXA"/> + <UMLRealTime:RTMessageSet xmi:id="_EEmFMNl6Eeabyf-IzF9zXA" base_Interface="_EESjMNl6Eeabyf-IzF9zXA" rtMsgKind="out"/> + <UMLRealTime:RTMessageSet xmi:id="_EEwdQNl6Eeabyf-IzF9zXA" base_Interface="_EErkwNl6Eeabyf-IzF9zXA" rtMsgKind="inOut"/> + <UMLRealTime:Protocol xmi:id="_EE0HoNl6Eeabyf-IzF9zXA" base_Collaboration="_EDFCQNl6Eeabyf-IzF9zXA"/> + <UMLRealTime:RTPort xmi:id="_R0lqUNl6Eeabyf-IzF9zXA" base_Port="_R0TWcNl6Eeabyf-IzF9zXA"/> +</xmi:XMI> diff --git a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/dialogs/ProtocolMessageProviderTest.java b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/dialogs/ProtocolMessageProviderTest.java new file mode 100644 index 000000000..213e5064a --- /dev/null +++ b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/dialogs/ProtocolMessageProviderTest.java @@ -0,0 +1,232 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA + * + * 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: + * Ansgar Radermacher - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrusrt.umlrt.tooling.ui.tests.dialogs; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.inject.Named; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.operations.IOperationHistory; +import org.eclipse.core.commands.operations.OperationHistoryFactory; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.papyrus.junit.utils.rules.HouseKeeper; +import org.eclipse.papyrus.junit.utils.rules.PluginResource; +import org.eclipse.papyrusrt.junit.rules.DataBindingsRule; +import org.eclipse.papyrusrt.junit.rules.FixtureElementRule; +import org.eclipse.papyrusrt.junit.rules.UMLRTModelSetFixture; +import org.eclipse.papyrusrt.umlrt.tooling.ui.providers.ProtocolMsgContentProvider; +import org.eclipse.uml2.uml.AnyReceiveEvent; +import org.eclipse.uml2.uml.Behavior; +import org.eclipse.uml2.uml.CallEvent; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Region; +import org.eclipse.uml2.uml.StateMachine; +import org.eclipse.uml2.uml.Transition; +import org.eclipse.uml2.uml.Trigger; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; + +/** + * Test suite for the protocol message provider used in the + * combined port and message dialog. + */ +@SuppressWarnings("nls") +@PluginResource("resource/dialogs/TriggerCreationTest.di") +public class ProtocolMessageProviderTest { + + /** + * expected protocol-message names + */ + protected static final String BASE_RESPONSE = "baseResponse"; + protected static final String BASE_REQUEST = "baseRequest"; + protected static final String SUB_RESPONSE = "subResponse"; + protected static final String SUB_REQUEST = "subRequest"; + protected static final String SUB_SUB_RESPONSE = "subSubResponse"; + protected static final String SUB_SUB_REQUEST = "subSubRequest"; + + @Rule + public final TestRule dataBindings = new DataBindingsRule(); + + @Rule + public final HouseKeeper housekeeper = new HouseKeeper(); + + @Rule + public final UMLRTModelSetFixture modelSet = new UMLRTModelSetFixture(); + + // init @Named fields + @Rule + public final FixtureElementRule elements = new FixtureElementRule(); + + protected TransactionalEditingDomain domain; + + @Named("RootElement::Capsule1") + protected Class capsule1; + + @Named("RootElement::Capsule1::base") + protected Port base; + + @Named("RootElement::Capsule1::sub") + protected Port sub; + + @Named("RootElement::Capsule1::subSub") + protected Port subSub; + + protected Transition t1; + + protected Trigger trigger; + + protected ProtocolMsgContentProvider provider; + + public ProtocolMessageProviderTest() { + super(); + } + + /** + * Configure trigger and ports + * + * @param ports + * @param conjugated + */ + protected void configureTriggerAndPorts(final List<Port> ports, boolean conjugated) { + AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(domain, "configure port", Collections.EMPTY_LIST) { + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + trigger = t1.createTrigger("testTrigger"); + trigger.getPorts().addAll(ports); + ports.forEach(port -> port.setIsConjugated(conjugated)); + return CommandResult.newOKCommandResult(); + } + }; + IOperationHistory history = OperationHistoryFactory.getOperationHistory(); + try { + history.execute(cmd, new NullProgressMonitor(), null); + } catch (ExecutionException e) { + fail("Can't execute command: " + e.getMessage()); + } + provider = new ProtocolMsgContentProvider(trigger); + } + + /** + * Test for events in case of base port + */ + @Test + public void checkEventsForBase() { + configureTriggerAndPorts(Arrays.asList(base), false); + + Object[] rootEvents = provider.getElements(); + assertThat("Single any event as root", rootEvents.length == 1); + assertThat("Root element must be an any-event", rootEvents[0] instanceof AnyReceiveEvent); + + Object[] children = provider.getChildren(null); + // the base protocol is not loaded during the test during test due to following exception: + // No service registered under 'interface org.eclipse.papyrusrt.umlrt.core.defaultlanguage.IDefaultLanguageService' + // => rtBound and rtUnbound are not part of the returned events + assertThat(String.format("Should contain a single in-request (have %d)", children.length), children.length == 1); + + Arrays.asList(children).forEach(child -> assertThat("All childs must be call events", child instanceof CallEvent)); + assertThat("Check name of third event", ((CallEvent) children[0]).getOperation().getName().equals(BASE_RESPONSE)); + } + + /** + * Test for events in case of subSub port + */ + @Test + public void checkEventsForSubSub() { + configureTriggerAndPorts(Arrays.asList(subSub), false); + + Object[] children = provider.getChildren(null); + assertThat(String.format("Should contain three in-requests (have %d)", children.length), children.length == 3); + Arrays.asList(children).forEach(child -> assertThat("All childs must be events", child instanceof CallEvent)); + + // check names (and order) of events + String msgName = ((CallEvent) children[0]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, BASE_RESPONSE), msgName.equals(BASE_RESPONSE)); + msgName = ((CallEvent) children[1]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, SUB_RESPONSE), msgName.equals(SUB_RESPONSE)); + msgName = ((CallEvent) children[2]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, SUB_SUB_RESPONSE), msgName.equals(SUB_SUB_RESPONSE)); + } + + /** + * Test for events in case of selecting two ports (sub and subSub) + */ + @Test + public void checkEventsForMultiSel() { + configureTriggerAndPorts(Arrays.asList(sub, subSub), false); + + Object[] children = provider.getChildren(null); + assertThat(String.format("Should contain two in-requests (have %d)", children.length), children.length == 2); + Arrays.asList(children).forEach(child -> assertThat("All childs must be call events", child instanceof CallEvent)); + + // check names (and order) of events + // should contain the base and sub events, since these are common for the two ports + String msgName = ((CallEvent) children[0]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, BASE_RESPONSE), msgName.equals(BASE_RESPONSE)); + msgName = ((CallEvent) children[1]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, SUB_RESPONSE), msgName.equals(SUB_RESPONSE)); + } + + /** + * Test for events in case of subSub port when conjugated + */ + @Test + public void checkEventsForSubSubConj() { + configureTriggerAndPorts(Arrays.asList(subSub), true); + + Object[] children = provider.getChildren(null); + assertThat(String.format("Should contain three out-requests (have %d)", children.length), children.length == 3); + Arrays.asList(children).forEach(child -> assertThat("All childs must be call events", child instanceof CallEvent)); + + // check names (and also order of events + String msgName = ((CallEvent) children[0]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, BASE_REQUEST), msgName.equals(BASE_REQUEST)); + msgName = ((CallEvent) children[1]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, SUB_REQUEST), msgName.equals(SUB_REQUEST)); + msgName = ((CallEvent) children[2]).getOperation().getName(); + assertThat(String.format("1st event is %s, should be %s", msgName, SUB_SUB_REQUEST), msgName.equals(SUB_SUB_REQUEST)); + } + + @Before + public void getModelReferences() { + + Behavior behavior = capsule1.getClassifierBehavior(); + assertThat("Capsule must have a state machine", behavior instanceof StateMachine); + StateMachine sm = (StateMachine) behavior; + + assertThat("SM must have at least one region", sm.getRegions().size() >= 1); + Region mainRegion = sm.getRegions().get(0); + + // choose first transition for trigger tests + assertThat("SM must have at least one transition", mainRegion.getTransitions().size() >= 1); + t1 = mainRegion.getTransitions().get(0); + + domain = TransactionUtil.getEditingDomain(t1); + } +} |