Author: objectiser
Date: 2009-01-22 15:41:48 -0500 (Thu, 22 Jan 2009)
New Revision: 467
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java
Log:
Added 'stateless' checkbox to generator dialog and pass through. Moved current
change rules to be stateful specific.
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-22
20:41:48 UTC (rev 467)
@@ -23,15 +23,15 @@
org.jboss.tools.overlord.cdl.runtime.jbossesb.editor.JBossESBConfigEditorManager,
org.jboss.tools.overlord.cdl.runtime.jbossesb.validation.ESBLanguageModelValidationRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.export.ESBLanguageModelStreamExportRule,
-
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.LanguageToConversationModelChangeRule,
-
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ConversationModelChangeRule,
-
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ConversationInteractionModelChangeRule,
-
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.MessageSignatureModelChangeRule,
-
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.TypeReferenceModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.IfModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ParallelModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.RunModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.SpawnModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhenModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhileModelChangeRule
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.LanguageToConversationModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationInteractionModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.MessageSignatureModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.TypeReferenceModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.IfModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ParallelModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.RunModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.SpawnModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhenModelChangeRule,
+
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhileModelChangeRule
Bundle-ActivationPolicy: lazy
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -112,12 +112,12 @@
gd=new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 1;
- gd.widthHint = 500;
+ gd.widthHint = 650;
gd.grabExcessHorizontalSpace = true;
group.setLayoutData(gd);
layout = new GridLayout();
- layout.numColumns = 4;
+ layout.numColumns = 6;
group.setLayout(layout);
// Labels
@@ -126,15 +126,23 @@
gd = new GridData();
gd.horizontalSpan = 2;
- gd.widthHint = 150;
+ gd.widthHint = 200;
label.setLayoutData(gd);
label = new Label(group, SWT.NONE);
+ label.setText("Stateless");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 60;
+ label.setLayoutData(gd);
+
+ label = new Label(group, SWT.NONE);
label.setText("Project Name");
gd = new GridData();
- gd.horizontalSpan = 2;
- gd.widthHint = 150;
+ gd.horizontalSpan = 3;
+ gd.widthHint = 300;
label.setLayoutData(gd);
if (m_conversationModel != null) {
@@ -147,7 +155,7 @@
gd = new GridData();
gd.horizontalSpan = 2;
- gd.widthHint = 150;
+ gd.widthHint = 200;
button.setLayoutData(gd);
m_roleButtons.add(button);
@@ -162,6 +170,26 @@
}
});
+ Button statelessButton=new Button(group, SWT.CHECK);
+ statelessButton.setSelection(true);
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 60;
+ statelessButton.setLayoutData(gd);
+
+ m_statelessButtons.add(statelessButton);
+
+ statelessButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ checkStatus();
+ }
+ });
+
Text projectName=new Text(group, SWT.NONE);
String prjName=m_roles.get(i).getName();
@@ -173,7 +201,7 @@
projectName.setText(prjName);
gd = new GridData();
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
gd.widthHint = 300;
projectName.setLayoutData(gd);
@@ -336,6 +364,7 @@
if (m_roleButtons.get(i).getSelection()) {
generator.generateRole(m_roles.get(i),
+ m_statelessButtons.get(i).getSelection(),
m_projectNames.get(i).getText());
}
}
@@ -374,6 +403,7 @@
private ConversationModel m_conversationModel=null;
private java.util.List<Role> m_roles=null;
private java.util.List<Button> m_roleButtons=new
java.util.Vector<Button>();
+ private java.util.List<Button> m_statelessButtons=new
java.util.Vector<Button>();
private java.util.List<Text> m_projectNames=new java.util.Vector<Text>();
private Combo m_build=null;
private java.util.List<BuildSystem> m_buildSystems=new
java.util.Vector<BuildSystem>();
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -120,10 +120,11 @@
* supplied role.
*
* @param role The role
+ * @param stateless Whether the generated role should be stateless
* @param projectName The project name
* @throws Exception Failed to generate role
*/
- public void generateRole(Role role, String projectName)
+ public void generateRole(Role role, boolean stateless, String projectName)
throws Exception {
if (logger.isLoggable(Level.FINEST)) {
@@ -145,6 +146,10 @@
((ConversationModel)localModel).getConversation() != null) {
ConversationModel lcm=(ConversationModel)localModel;
+ // Check if stateless version of model is required
+ if (stateless) {
+ }
+
ModelReference targetRef=
new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -107,7 +107,7 @@
// Check that it is a conversation based ESB action
if (actionType.startsWith(MODEL_ACTION_PACKAGE)) {
- actionType = actionType.substring(CONVERSATION_ACTION_PACKAGE.length());
+ actionType = actionType.substring(MODEL_ACTION_PACKAGE.length());
String stateValue=null;
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -34,6 +34,8 @@
public abstract class AbstractESBAction extends ModelObject
implements ESBAction {
+ private static final long serialVersionUID = -5660683702154455942L;
+
public static final String ACTION_ELEMENT = "action";
public static final String VALUE_ATTR = "value";
public static final String NAME_ATTR = "name";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -32,6 +32,8 @@
*/
public abstract class AbstractStatefulESBAction extends AbstractESBAction {
+ private static final long serialVersionUID = -2818664861342681505L;
+
public static final String IDENTITIES = "identities";
public static final String ACTION_ELEMENT = "action";
public static final String VALUE_ATTR = "value";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class IfAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 9064103072852303673L;
+
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
public static final String IMMEDIATE = "immediate";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -41,6 +41,8 @@
*/
public class MessageRouterAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -7335984128887046476L;
+
public static final String IDENTITIES_ELEMENT = "identities";
public static final String INITIATE = "initiate";
public static final String SERVICE_NAME = "service-name";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class ParallelAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 6269914598525068328L;
+
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
public static final String IMMEDIATE = "immediate";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -31,6 +31,8 @@
*/
public class PerformAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 6342595605838714160L;
+
private static final String BIND_ELEMENT = "bind";
private static final String TO_VARIABLE_ATTR = "to-variable";
public static final String SERVICE_NAME = "serviceName";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -28,6 +28,8 @@
*/
public class ReceiveMessageAction extends AbstractInteractionMessageAction {
+ private static final long serialVersionUID = 2272649736091582501L;
+
/**
* The constructor for the action.
*
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -29,6 +29,8 @@
*/
public class RetrieveSessionAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -1468908746103555375L;
+
public static final String IDENTITIES = "identities";
/**
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -29,6 +29,8 @@
*/
public class ScheduleStateAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -8137315455582602258L;
+
public static final String IMMEDIATE = "immediate";
public static final String SERVICE_NAME = "serviceName";
public static final String SERVICE_CATEGORY = "serviceCategory";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class SendMessageAction extends AbstractInteractionMessageAction {
+ private static final long serialVersionUID = 6415982439018207905L;
+
public static final String RESPONSE_SERVICE_NAME = "responseServiceName";
public static final String RESPONSE_SERVICE_CATEGORY =
"responseServiceCategory";
public static final String SERVICE_NAME = "serviceName";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -28,6 +28,8 @@
*/
public class SetMessageAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -927023877167087363L;
+
public static final String STATE_EXPRESSION = "stateExpression";
public static final String HEADER_PROPERTY = "headerProperty";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -32,6 +32,8 @@
*/
public class SetStateAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 1433577447941826202L;
+
public static final String STATE_EXPRESSION = "stateExpression";
public static final String MESSAGE_EXPRESSION = "messageExpression";
public static final String VARIABLE = "variable";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -31,6 +31,8 @@
*/
public class SwitchAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -114174911606651401L;
+
public static final String TYPE_ATTR = "type";
public static final String MESSAGE_ELEMENT = "message";
private static final String SERVICE_NAME = "service-name";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -29,6 +29,8 @@
*/
public class UnsupportedAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 61328489127442228L;
+
/**
* The constructor for the action.
*
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class WhenAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 3009772810014450672L;
+
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
private static final String WHEN = "when";
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class WhileAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -4863147208782217805L;
+
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
public static final String IMMEDIATE = "immediate";
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,173 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.scribble.conversation.model.ConversationInteraction;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-
-/**
- * This is the abstract ESB model change rule.
- */
-public abstract class AbstractESBModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if ((context.getParent() instanceof ESBService ||
- (ref != null && ref.getSource().getObject()
- instanceof AbstractStatefulESBAction &&
- ((AbstractStatefulESBAction)ref.getSource().getObject()).getService() != null))
&&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method returns the ESB service associated with the
- * optional model object reference or the context.
- *
- * @param context The context
- * @param ref The optional model object
- * @return The ESB service, or null if not found
- */
- protected ESBService getESBService(ModelChangeContext context,
- ModelObject ref) {
- ESBService ret=(ESBService)context.getParent();
-
- if (ref != null && ref.getSource().getObject() instanceof
AbstractStatefulESBAction) {
- ret = ((AbstractStatefulESBAction)ref.getSource().getObject()).getService();
- }
-
- return(ret);
- }
-
- /**
- * This method determines the position of the supplied
- * model object within the supplied service.
- *
- * @param service The service
- * @param ref The optional model object
- * @return The position, or -1 if not found
- */
- protected int getPosition(ESBService service, ModelObject ref) {
- int ret=-1;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
- ret = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether an 'initiator' action,
- * inserted at the defined position in the specified
- * service, should actually be placed in a new scheduled
- * service.
- *
- * @param service The current service
- * @param pos The insertion position in that service
- * @return Whether a new service needs to be scheduled to
- * accommodate the initiator action
- */
- protected boolean shouldScheduleNewService(ESBService service,
- int pos) {
- boolean ret=false;
-
- for (int i=0; ret == false && i < pos; i++) {
- ESBAction action=service.getActions().get(i);
-
- if (action.isSessionBased() && !action.isSessionType()) {
- ret = true;
- }
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj.getSource().getObject() instanceof AbstractStatefulESBAction &&
- (context.getParent() instanceof ESBService ||
- ((AbstractStatefulESBAction)mobj.getSource().getObject()).getService() != null)
&&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method removes the supplied model object from the
- * supplied model. The model object representation must
- * contain the necessary model specific to remove the
- * object from the underlying model representation.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object to be deleted
- * @return Whether the change has been applied
- */
- @Override
- public boolean delete(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
- ESBService service=getESBService(context, mobj);
- ESBAction action=(ESBAction)mobj.getSource().getObject();
-
- if (action != null && service != null) {
- ret = service.getActions().remove(action);
- }
-
- return(ret);
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,553 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.IdentityUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryInfo;
-
-/**
- * This is the model change rule for the Conversation Interaction.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ConversationInteractionModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj,
- ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof ConversationInteraction &&
- super.isInsertSupported(context, model, mobj, ref)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ConversationInteraction interaction=(ConversationInteraction)mobj;
-
- // Check if send or receive
- if (InteractionUtil.isSend(interaction)) {
-
- // Send
- insertSend(context, esbModel, interaction, ref);
-
- } else {
- // Receive
- insertReceive(context, esbModel, interaction, ref);
- }
-
- return(true);
- }
-
- protected void insertSend(ModelChangeContext context,
- ESBLanguageModel esbModel, ConversationInteraction interaction,
- ModelObject ref) {
- ESBService service=getESBService(context, ref);
-
- SendMessageAction action=
- new SendMessageAction(service);
-
- if (interaction.getMessageSignature().getOperation() != null) {
- action.setOperation(interaction.getMessageSignature().getOperation());
- }
-
- setMessageType(action, interaction);
-
- boolean f_subsequentInitiator=false;
- boolean f_moveActions=false;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- int pos=getPosition(service, ref);
-
- // Check if subsequent action(s) are initiators
- if (pos != -1) {
- for (int i=pos; f_subsequentInitiator == false &&
- i < service.getActions().size(); i++) {
- f_subsequentInitiator =
- service.getActions().get(i).isInitiator();
- }
- }
-
- // Move actions if a subsequent initiator has been found
- f_moveActions = f_subsequentInitiator;
-
- service.addAction(action, pos);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action
&&
- interaction.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)interaction.getEnclosingDefinition())));
- }
-
- if (interaction.getRequestLabel() != null) {
-
- // Create new ESB service
- ESBService respService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(respService);
-
- action.setResponseDestination(respService.getCategory(),
- respService.getName());
-
- context.setParent(respService);
-
- // Clear the sub-sequent initiator flag, as
- // subsequent actions will be moved to new service
- // anyway
- f_subsequentInitiator = false;
-
- } else if (interaction.getReplyToLabel() != null) {
-
- if (interaction.getToRole() != null) {
- action.setClientEPR(interaction.getToRole().getName());
- } else {
- action.setClientEPR("client");
- }
- }
-
- // Check if subsequent initiator found, requiring
- // a new service
- if (f_subsequentInitiator) {
-
- ESBService extraService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(extraService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(extraService.getCategory(),
- extraService.getName(), false);
-
- service.addAction(schedule, pos+1);
-
- // Move pointer on, as now additional 'schedule' action
- pos++;
-
- context.setParent(extraService);
- }
-
- // Check if existing actions need to be moved
- if (f_moveActions) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBService extraService=(ESBService)context.getParent();
-
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- extraService.addAction(act, -1);
- }
- }
-
- // If not reply, then include the target service
- // details
- if (interaction.getReplyToLabel() == null &&
- interaction.getToRole() != null &&
- interaction.getToRole().getName() != null &&
- interaction.getToRole().getName().length() > 0) {
- String roleName=Character.toLowerCase(
- interaction.getToRole().getName().charAt(0))+
- interaction.getToRole().getName().substring(1);
-
- action.setDestinationExpression(
- InteractionUtil.getRoleServiceCategoryProperty(roleName),
- InteractionUtil.getRoleServiceNameProperty(roleName));
- }
-
- if (interaction.getEnclosingDefinition() instanceof Conversation &&
- interaction.getEnclosingDefinition().getModel()
- instanceof ConversationModel) {
-
- java.util.List<Identity> ids=((Conversation)
- interaction.getEnclosingDefinition()).getIdentities();
-
- java.util.List<IdentityLocator> locators=
- ((ConversationModel)interaction.getEnclosingDefinition().
- getModel()).getIdentityLocators();
-
- IdentityUtil.defineIdentities(action.getPropertyElement(
- SendMessageAction.IDENTITIES),
- interaction.getMessageSignature(), ids, locators);
- }
- }
-
- protected void insertReceive(ModelChangeContext context,
- ESBLanguageModel esbModel, ConversationInteraction interaction,
- ModelObject ref) {
- ESBService service=getESBService(context, ref);
- ESBService endService=service;
-
- int endPos=-1;
- boolean f_subsequentInitiator=false;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- int pos=getPosition(service, ref);
-
- // Check if subsequent action(s) are initiators
- if (pos != -1) {
- for (int i=pos; f_subsequentInitiator == false &&
- i < service.getActions().size(); i++) {
- f_subsequentInitiator =
- service.getActions().get(i).isInitiator();
- }
- }
-
- endPos = pos;
-
- // Check if receive needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- // Already has activities, so need to separate
- // into another service descriptor
- ESBService recvService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(recvService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(recvService.getCategory(),
- recvService.getName(), false);
-
- service.addAction(schedule, pos);
-
- context.setParent(recvService);
-
- endService = recvService;
- endPos = 0;
- }
-
- ReceiveMessageAction action=
- new ReceiveMessageAction(endService);
-
- if (interaction.getMessageSignature().getOperation() != null) {
- action.setOperation(interaction.getMessageSignature().getOperation());
- }
-
- setMessageType(action, interaction);
-
- endService.addAction(action, endPos);
-
- if (endService.getFirstSessionBasedAction() == action &&
- interaction.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)interaction.getEnclosingDefinition())));
- }
-
- // Check if subsequent initiator found, requiring
- // a new service
- if (f_subsequentInitiator) {
-
- ESBService extraService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(endService.getCategory(),
- endService.getName()));
-
- esbModel.addService(extraService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(endService);
-
- schedule.setDestination(extraService.getCategory(),
- extraService.getName(), false);
-
- endService.addAction(schedule, endPos+1);
-
- // Move pointer on, as now additional 'schedule' action
- pos++;
-
- context.setParent(extraService);
-
- endService = extraService;
- endPos = -1;
- }
-
- // Check if existing actions need to be moved
- if (pos != -1 && service != endService) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- endService.addAction(act, -1);
- }
- }
-
- // If not a response, then add to the gateway
- if (interaction.getReplyToLabel() == null) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- java.util.List<MessageSignature> mtypes=
- new java.util.Vector<MessageSignature>();
- mtypes.add(interaction.getMessageSignature());
-
- mra.addRoute(endService.getCategory(),
- endService.getName(),
- service.isRoot(), mtypes);
- }
- }
-
- // Set client EPR
- if (interaction.getFromRole() != null) {
- action.setClientEPR(interaction.getFromRole().getName());
- } else {
- action.setClientEPR("client");
- }
- }
-
- if (interaction.getEnclosingDefinition() instanceof Conversation &&
- interaction.getEnclosingDefinition().getModel()
- instanceof ConversationModel) {
-
- java.util.List<Identity> ids=((Conversation)
- interaction.getEnclosingDefinition()).getIdentities();
-
- java.util.List<IdentityLocator> locators=
- ((ConversationModel)interaction.getEnclosingDefinition().
- getModel()).getIdentityLocators();
-
- IdentityUtil.defineIdentities(action.getPropertyElement(
- SendMessageAction.IDENTITIES),
- interaction.getMessageSignature(), ids, locators);
- }
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and modified model object.
- *
- * @param context The context
- * @param model The model
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isUpdateSupported(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
-
- if (fromObj instanceof ConversationInteraction &&
- toObj instanceof ConversationInteraction &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method modifies an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @param context The context
- * @param model The model being changed
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the change has been applied
- */
- @Override
- public boolean update(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
- ConversationInteraction toInteraction=(ConversationInteraction)toObj;
- ESBService service=(ESBService)context.getParent();
-
- // Get action from 'toInteraction'
- if (toInteraction.getSource().getObject() instanceof
- AbstractInteractionMessageAction) {
- AbstractInteractionMessageAction ma=
- (AbstractInteractionMessageAction)
- toInteraction.getSource().getObject();
-
- String origMesgType=ma.getMessageType();
-
- // Set message type
- setMessageType(ma, fromInteraction);
-
- // Update message type in router if appropriate
- if (InteractionUtil.isSend(fromInteraction) == false &&
- fromInteraction.getReplyToLabel() == null) {
- updateRouterMessageType(esbModel, service,
- origMesgType, ma);
- }
-
- ret = true;
- }
-
- return(ret);
- }
-
- protected void updateRouterMessageType(ESBLanguageModel esbModel,
- ESBService service, String origMesgType,
- AbstractInteractionMessageAction ma) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
- service.getName());
-
- if (route != null) {
- org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- org.w3c.dom.Element mesg=
- (org.w3c.dom.Element)nl.item(i);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
- equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
- ma.getMessageType());
- }
- }
- }
- }
- }
- }
- }
-
- protected void setMessageType(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
-
- if (interaction.getMessageSignature().getTypes().size() == 1) {
- TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
-
- // TODO: Search for an implementation associated with
- // the type reference, so that the type can be
- // abstract - possibly have the required message type
- // notation as part of the context, so that if multiple
- // implementations found, then can select e.g. XML or
- // Java as message type representation.
- String mtype=InteractionUtil.getTypeString(ref);
-
- action.setMessageType(mtype);
- }
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj instanceof ConversationInteraction &&
- super.isDeleteSupported(context, model, mobj)) {
- ret = true;
- }
-
- return(ret);
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,181 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryInfo;
-
-/**
- * This is the model change rule for the Conversation.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ConversationModelChangeRule extends AbstractModelChangeRule {
-
- private static final String NAME_SUFFIX = "_main";
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object causing the change
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Conversation &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- Conversation conv=(Conversation)mobj;
-
- String namespace=((Model)conv.getModel()).
- getNamespace().getName();
-
- String category=ConversationUtil.getServiceCategory(conv);
-
- String name=ConversationUtil.getServiceName(conv);
-
- String sdname="";
-
- // Check if root conversation
- if (conv.getParent() instanceof Model) {
-
- // Register gateway service
- DefaultESBService gateway=new DefaultESBService(esbModel,
- category, name);
-
- MessageRouterAction mra=new MessageRouterAction(gateway);
-
- // Construct service description name
- if (namespace != null) {
- sdname = "{"+namespace+"}";
- }
-
- sdname += conv.getModelName().getName()+"-"+
- conv.getModelName().getLocatedRole().getName();
-
- mra.setServiceDescriptionName(sdname);
-
- gateway.addAction(mra, -1);
-
- esbModel.addService(gateway);
-
- name += NAME_SUFFIX;
- }
-
- // Create new ESB service
- ESBService service=esbModel.createService(category, name);
-
- esbModel.addService(service);
-
- // Create 'CreateSession' activity
- CreateSessionAction csa=new CreateSessionAction(service);
-
- // Check if root conversation
- if (conv.getParent() instanceof Model) {
- csa.setRoot(true);
-
- String ctype=null;
-
- // Check if conversation has a 'conforms to' reference
- if (conv.getConformsTo().size() > 0) {
- // Set conversation type based on first 'conforms to'
- // reference
- ConformanceReference cref=conv.getConformsTo().get(0);
-
- ctype = cref.getNamespace()+"."+
- cref.getLocalpart()+"@"+
- cref.getLocatedRole();
- } else {
- // Set conversation type based on conversation
- // namespace and name
- ctype = namespace+"."+
- conv.getModelName().getName()+"@"+
- conv.getModelName().getLocatedRole().getName();
- }
-
- if (ctype != null) {
- csa.setConversationType(ctype);
- }
- }
-
- csa.setServiceDescriptionName(sdname);
- csa.setBusinessObjectType(ConversationUtil.getBusinessObjectType(conv));
-
- service.addAction(csa, -1);
-
- // Process the activities within the conversation
- java.util.List<Activity> acts=conv.getBlock().getContents();
-
- context.setParent(service);
-
- for (int i=0; i < acts.size(); i++) {
- context.insert(model, acts.get(i), null);
- }
-
- return(true);
- }
-
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,416 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the If grouping construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class IfModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof If &&
- super.isInsertSupported(context, model, mobj, ref)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- If ifElem=(If)mobj;
-
- int pos=getPosition(service, ref);
-
- ESBService joinService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(joinService);
-
- // Check if should be an 'if' or a 'switch' action
- if (ifElem.getRoles().contains(context.getRole())) {
-
- insertIf(context, model, service, ifElem, joinService, pos);
- } else {
- insertSwitch(context, model, service, ifElem, joinService, pos);
- }
-
-
- context.setParent(joinService);
-
- // If reference provided, then move subsequent activities
- // to the 'join service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- joinService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- protected void insertIf(ModelChangeContext context,
- Model model, ESBService service,
- If ifElem, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- // If action, because the role is a decision maker
- IfAction ifAction=new IfAction(service);
-
- service.addAction(ifAction, pos);
-
- for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
-
- boolean immediate=false;
-
- ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
- subService.getCategory(), subService.getName(),
- immediate, null, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- if (ifElem.getElseBlock() != null) {
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
- context.insert(model,
- ifElem.getElseBlock().getContents().get(j), null);
- }
-
- boolean immediate=false;
-
- ifAction.addPath(IfAction.ELSE,
- subService.getCategory(), subService.getName(),
- immediate, null, -1);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- if (service.getFirstSessionBasedAction() == ifAction &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- protected void insertSwitch(ModelChangeContext context,
- Model model, ESBService service,
- If ifElem, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- // Check if 'when' needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- // Already has activities, so need to separate
- // into another service descriptor
- ESBService switchService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(switchService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(switchService.getCategory(),
- switchService.getName(), false);
-
- service.addAction(schedule, pos);
-
- context.setParent(switchService);
-
- service = switchService;
- pos = -1;
- }
-
- // Switch action, as role is a decision observer
- SwitchAction switchAction=new SwitchAction(service);
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
-
- service.addAction(switchAction, pos);
-
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
-
- for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(cb);
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
- }
-
- if (ifElem.getElseBlock() != null) {
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
- context.insert(model,
- ifElem.getElseBlock().getContents().get(j), null);
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(ifElem.getElseBlock());
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, -1);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
- }
-
- // Only record message router 'routes' if the switch
- // receives request interactions, and it is the first
- // session based action in the service
- if (messageTypes.size() > 0 &&
- service.getFirstSessionBasedAction() == switchAction) {
- ESBService gwService=
- esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- mra.addRoute(service.getCategory(),
- service.getName(),
- false, messageTypes);
- }
- }
- }
-
- if (service.getFirstSessionBasedAction() == switchAction &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryInfo;
-
-/**
- * This is the model change rule for the Language Model to
- * Conversation Model.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class LanguageToConversationModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof ConversationModel &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ConversationModel cm=(ConversationModel)mobj;
-
- if (cm.getConversation() != null) {
- context.insert(model, cm.getConversation(), null);
- }
-
- return(true);
- }
-
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,180 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryInfo;
-
-/**
- * This is the model change rule for the MessageSignature.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class MessageSignatureModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and modified model object.
- *
- * @param context The context
- * @param model The model
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isUpdateSupported(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
-
- if (fromObj instanceof MessageSignature &&
- toObj instanceof MessageSignature &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method modifies an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @param context The context
- * @param model The model being changed
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the change has been applied
- */
- @Override
- public boolean update(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- MessageSignature fromMS=(MessageSignature)fromObj;
- MessageSignature toMS=(MessageSignature)toObj;
- ConversationInteraction toInteraction=null;
- ConversationInteraction fromInteraction=null;
-
- if (toMS != null &&
- toMS.getParent() instanceof ConversationInteraction) {
- toInteraction = (ConversationInteraction)toMS.getParent();
- }
-
- if (fromMS != null &&
- fromMS.getParent() instanceof ConversationInteraction) {
- fromInteraction = (ConversationInteraction)fromMS.getParent();
- }
-
- // Get action from 'toInteraction'
- if (toInteraction != null &&
- toInteraction.getSource().getObject() instanceof
- AbstractInteractionMessageAction) {
- AbstractInteractionMessageAction ma=
- (AbstractInteractionMessageAction)
- toInteraction.getSource().getObject();
-
- // Update operation
- setOperation(ma, fromInteraction);
-
- ESBService service = ma.getService();
-
- String origMesgType=ma.getMessageType();
-
- // Set message type
- setMessageType(ma, fromInteraction);
-
- // Update message type in router if appropriate
- if (InteractionUtil.isSend(fromInteraction) == false &&
- fromInteraction.getReplyToLabel() == null) {
- updateRouterMessageType(esbModel, service,
- origMesgType, ma);
- }
-
- ret = true;
- }
-
- return(ret);
- }
-
- protected void updateRouterMessageType(ESBLanguageModel esbModel,
- ESBService service, String origMesgType,
- AbstractInteractionMessageAction ma) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
- service.getName());
-
- if (route != null) {
- org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- org.w3c.dom.Element mesg=
- (org.w3c.dom.Element)nl.item(i);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
- equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
- ma.getMessageType());
- }
- }
- }
- }
- }
- }
- }
-
- protected void setMessageType(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
-
- if (interaction.getMessageSignature().getTypes().size() == 1) {
- TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
-
- // TODO: Search for an implementation associated with
- // the type reference, so that the type can be
- // abstract - possibly have the required message type
- // notation as part of the context, so that if multiple
- // implementations found, then can select e.g. XML or
- // Java as message type representation.
- String mtype=InteractionUtil.getTypeString(ref);
-
- action.setMessageType(mtype);
- }
- }
-
- protected void setOperation(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
- action.setOperation(interaction.getMessageSignature().getOperation());
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,192 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the Parallel grouping construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ParallelModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Parallel &&
- super.isInsertSupported(context, model, mobj, ref)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- Parallel parallel=(Parallel)mobj;
-
- int pos=getPosition(service, ref);
-
- // Create the join service
- ESBService joinService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(joinService);
-
- // Create and configure the parallel action
- ParallelAction parAction=new ParallelAction(service);
-
- service.addAction(parAction, pos);
-
- for (int i=0; i < parallel.getBlocks().size(); i++) {
- Block b=parallel.getBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < b.getContents().size(); j++) {
- context.insert(model, b.getContents().get(j), null);
- }
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- parallel.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)parallel.getEnclosingDefinition())));
- }
-
- boolean immediate=true;
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to get lookahead analyser");
- } else {
- java.util.Iterator<Interaction> iter=
- la.getInteractions(b, true).iterator();
-
- while (immediate && iter.hasNext()) {
- Interaction interaction=iter.next();
-
- // If interaction is a receive, then immediate
- // invocation will be false
- immediate = InteractionUtil.isSend(interaction);
- }
- }
-
- parAction.addPath(subService.getCategory(),
- subService.getName(), immediate, false, i);
- }
-
- context.setParent(joinService);
-
- parAction.addPath(joinService.getCategory(),
- joinService.getName(), false, true, -1);
-
- // Check if business object type needs to be specified
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == parAction
&&
- parallel.getEnclosingDefinition() instanceof Conversation) {
- parAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)parallel.getEnclosingDefinition())));
- }
-
- // If reference provided, then move subsequent activities
- // to the 'join service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- joinService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,201 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the Run composition construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class RunModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Run &&
- super.isInsertSupported(context, model, mobj, ref)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- Run run=(Run)mobj;
-
- int pos=getPosition(service, ref);
-
- PerformAction action=new PerformAction(service);
-
- service.addAction(action, pos);
-
- String category=ConversationUtil.getServiceCategory(run.getDefinition());
- String name=ConversationUtil.getServiceName(run.getDefinition());
-
- action.setDestination(category, name);
-
- // Check if business object type needs to be specified
- if (service.getFirstSessionBasedAction() == action &&
- run.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)run.getEnclosingDefinition())));
- }
-
- // Create return service
- ESBService returnService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(returnService);
-
- context.setParent(returnService);
-
- action.setReturnDestination(returnService.getCategory(),
- returnService.getName());
-
- // If reference provided, then move subsequent activities
- // to the 'return service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- returnService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj instanceof Run &&
- super.isDeleteSupported(context, model, mobj)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method removes the supplied model object from the
- * supplied model. The model object representation must
- * contain the necessary model specific to remove the
- * object from the underlying model representation.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object to be deleted
- * @return Whether the change has been applied
- */
- @Override
- public boolean delete(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
- ESBService service=getESBService(context, mobj);
- ESBAction action=(ESBAction)mobj.getSource().getObject();
-
- int pos=getPosition(service, mobj);
-
- if (action instanceof PerformAction && pos != -1) {
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- PerformAction perform=(PerformAction)action;
-
- schedule.setDestination(perform.getPropertyValue(PerformAction.RETURN_SERVICE_CATEGORY),
- perform.getPropertyValue(PerformAction.RETURN_SERVICE_NAME), true);
-
- service.addAction(schedule, pos);
-
- ret = super.delete(context, model, mobj);
- }
-
- return(ret);
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-//import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the Spawn composition construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class SpawnModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Spawn &&
- super.isInsertSupported(context, model, mobj, ref)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBService service=getESBService(context, ref);
- Spawn spawn=(Spawn)mobj;
-
- int pos=getPosition(service, ref);
-
- PerformAction action=new PerformAction(service);
-
- service.addAction(action, pos);
-
- String category=ConversationUtil.getServiceCategory(spawn.getDefinition());
- String name=ConversationUtil.getServiceName(spawn.getDefinition());
-
- action.setDestination(category, name);
-
- // Check if business object type needs to be specified
- if (service.getFirstSessionBasedAction() == action &&
- spawn.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)spawn.getEnclosingDefinition())));
- }
-
- return(true);
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj instanceof Spawn &&
- super.isDeleteSupported(context, model, mobj)) {
- ret = true;
- }
-
- return(ret);
- }
-
- //private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,172 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryInfo;
-
-/**
- * This is the model change rule for the Type Reference.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class TypeReferenceModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and modified model object.
- *
- * @param context The context
- * @param model The model
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isUpdateSupported(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
-
- if (fromObj instanceof TypeReference &&
- toObj instanceof TypeReference &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method modifies an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @param context The context
- * @param model The model being changed
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the change has been applied
- */
- @Override
- public boolean update(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- TypeReference fromTypeRef=(TypeReference)fromObj;
- TypeReference toTypeRef=(TypeReference)toObj;
- ConversationInteraction toInteraction=null;
- ConversationInteraction fromInteraction=null;
-
- if (toTypeRef != null && toTypeRef.getParent() instanceof MessageSignature
&&
- toTypeRef.getParent().getParent() instanceof ConversationInteraction) {
- toInteraction = (ConversationInteraction)toTypeRef.getParent().getParent();
- }
-
- if (fromTypeRef != null && fromTypeRef.getParent() instanceof MessageSignature
&&
- fromTypeRef.getParent().getParent() instanceof ConversationInteraction) {
- fromInteraction = (ConversationInteraction)fromTypeRef.getParent().getParent();
- }
-
- // Get action from 'toInteraction'
- if (toInteraction != null &&
- toInteraction.getSource().getObject() instanceof
- AbstractInteractionMessageAction) {
- AbstractInteractionMessageAction ma=
- (AbstractInteractionMessageAction)
- toInteraction.getSource().getObject();
-
- ESBService service = ma.getService();
-
- String origMesgType=ma.getMessageType();
-
- // Set message type
- setMessageType(ma, fromInteraction);
-
- // Update message type in router if appropriate
- if (InteractionUtil.isSend(fromInteraction) == false &&
- fromInteraction.getReplyToLabel() == null) {
- updateRouterMessageType(esbModel, service,
- origMesgType, ma);
- }
-
- ret = true;
- }
-
- return(ret);
- }
-
- protected void updateRouterMessageType(ESBLanguageModel esbModel,
- ESBService service, String origMesgType,
- AbstractInteractionMessageAction ma) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
- service.getName());
-
- if (route != null) {
- org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- org.w3c.dom.Element mesg=
- (org.w3c.dom.Element)nl.item(i);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
- equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
- ma.getMessageType());
- }
- }
- }
- }
- }
- }
- }
-
- protected void setMessageType(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
-
- if (interaction.getMessageSignature().getTypes().size() == 1) {
- TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
-
- // TODO: Search for an implementation associated with
- // the type reference, so that the type can be
- // abstract - possibly have the required message type
- // notation as part of the context, so that if multiple
- // implementations found, then can select e.g. XML or
- // Java as message type representation.
- String mtype=InteractionUtil.getTypeString(ref);
-
- action.setMessageType(mtype);
- }
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,322 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the When grouping construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhenModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof When &&
- super.isInsertSupported(context, model, mobj, ref)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- When when=(When)mobj;
-
- int pos=getPosition(service, ref);
-
- // Create join service
- ESBService joinService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(joinService);
-
- // Check if context role is decision maker
- if (when.getRoles().contains(context.getRole())) {
-
- insertWhen(context, model, service,
- when, joinService, pos);
- } else {
- insertSwitch(context, model, service,
- when, joinService, pos);
- }
-
- context.setParent(joinService);
-
- // If reference provided, then move subsequent activities
- // to the 'join service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- joinService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- protected void insertWhen(ModelChangeContext context,
- Model model, ESBService service,
- When when, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- WhenAction action=new WhenAction(service);
-
- service.addAction(action, pos);
-
- for (int i=0; i < when.getConditionalBlocks().size(); i++) {
- ConditionalBlock b=when.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < b.getContents().size(); j++) {
- context.insert(model, b.getContents().get(j), null);
- }
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
-
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- when.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
-
- action.addPath(subService.getCategory(),
- subService.getName(), i);
- }
-
- if (service.getFirstSessionBasedAction() == action &&
- when.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
- }
-
- protected void insertSwitch(ModelChangeContext context,
- Model model, ESBService service,
- When when, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- // Check if 'when' needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- // Already has activities, so need to separate
- // into another service descriptor
- ESBService switchService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(switchService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(switchService.getCategory(),
- switchService.getName(), false);
-
- service.addAction(schedule, pos);
-
- context.setParent(switchService);
-
- service = switchService;
- pos = -1;
- }
-
- // Switch action, as role is a decision observer
- SwitchAction switchAction=new SwitchAction(service);
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
-
- service.addAction(switchAction, pos);
-
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
-
- for (int i=0; i < when.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=when.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(cb);
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
-
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- when.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
- }
-
- // Only record message router 'routes' if the switch
- // receives request interactions, and it is the first
- // session based action in the service
- if (messageTypes.size() > 0 &&
- service.getFirstSessionBasedAction() == switchAction) {
- ESBService gwService=
- esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- mra.addRoute(service.getCategory(),
- service.getName(),
- false, messageTypes);
- }
- }
- }
-
- if (service.getFirstSessionBasedAction() == switchAction &&
- when.getEnclosingDefinition() instanceof Conversation) {
- switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,246 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the While repetition construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhileModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof While &&
- super.isInsertSupported(context, model, mobj, ref)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method adds a new model object, within a
- * parent model object, with the details supplied in
- * another model object. The supplied model object
- * will usually be from a different model representation
- * (e.g. due to a merge), so the details will be
- * copied and placed in the representation associated
- * with the supplied model and parent model object.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- ESBService original=service;
- While whileElem=(While)mobj;
-
- int pos=getPosition(service, ref);
-
- // Check if action needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- ESBService whileService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(whileService);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- // 'immediate' flag set depending on whether the role
- // is an initiator of the while. If not, then the
- // immediate flag is false, which means the loop will be
- // evaluated based on the next received message
- schedule.setDestination(whileService.getCategory(),
- whileService.getName(),
- whileElem.getRoles().contains(context.getRole()));
- service.addAction(schedule, pos);
-
- context.setParent(whileService);
-
- service = whileService;
- }
-
- WhileAction action=new WhileAction(service);
-
- service.addAction(action, -1);
-
- // Check if business object type needs to be specified
- if (service.getFirstSessionBasedAction() == action &&
- whileElem.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)whileElem.getEnclosingDefinition())));
- }
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- // Configure the while loop service
- context.setParent(subService);
-
- for (int j=0; j < whileElem.getBlock().getContents().size(); j++) {
- context.insert(model, whileElem.getBlock().getContents().get(j), null);
- }
-
- // Need to insert a 'ScheduleStateAction' to return back
- // to the 'WhileAction', to re-evaluate the expression
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- // 'immediate' flag set depending on whether the role
- // is an initiator of the while. If not, then the
- // immediate flag is false, which means the loop will be
- // evaluated based on the next received message
- schedule.setDestination(service.getCategory(),
- service.getName(),
- whileElem.getRoles().contains(context.getRole()));
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- // Check if business object type needs to be specified
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
- whileElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)whileElem.getEnclosingDefinition())));
- }
-
- // Check whether message types need to be defined in
- // place of an expression
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
-
- // Check if context role is NOT the decision maker
- if (whileElem.getRoles().contains(context.getRole()) == false) {
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(whileElem.getBlock());
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
-
- }
-
- action.addPath(subService.getCategory(),
- subService.getName(), false, messageTypes, -1);
-
- // Create exit service
- ESBService exitService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(exitService);
-
- context.setParent(exitService);
-
- action.addPath(exitService.getCategory(),
- exitService.getName(), true,
- new java.util.Vector<MessageSignature>(), -1);
-
- // If reference provided, then move subsequent activities
- // to the 'exit service'
- if (pos != -1) {
- for (int i=pos+1; i < original.getActions().size();) {
- ESBAction act=original.getActions().get(i);
- original.getActions().remove(i);
-
- exitService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
(from rev 462,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+
+/**
+ * This is the abstract ESB model change rule.
+ */
+public abstract class AbstractESBModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if ((context.getParent() instanceof ESBService ||
+ (ref != null && ref.getSource().getObject()
+ instanceof AbstractStatefulESBAction &&
+ ((AbstractStatefulESBAction)ref.getSource().getObject()).getService() != null))
&&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the ESB service associated with the
+ * optional model object reference or the context.
+ *
+ * @param context The context
+ * @param ref The optional model object
+ * @return The ESB service, or null if not found
+ */
+ protected ESBService getESBService(ModelChangeContext context,
+ ModelObject ref) {
+ ESBService ret=(ESBService)context.getParent();
+
+ if (ref != null && ref.getSource().getObject() instanceof
AbstractStatefulESBAction) {
+ ret = ((AbstractStatefulESBAction)ref.getSource().getObject()).getService();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the position of the supplied
+ * model object within the supplied service.
+ *
+ * @param service The service
+ * @param ref The optional model object
+ * @return The position, or -1 if not found
+ */
+ protected int getPosition(ESBService service, ModelObject ref) {
+ int ret=-1;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+ ret = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether an 'initiator' action,
+ * inserted at the defined position in the specified
+ * service, should actually be placed in a new scheduled
+ * service.
+ *
+ * @param service The current service
+ * @param pos The insertion position in that service
+ * @return Whether a new service needs to be scheduled to
+ * accommodate the initiator action
+ */
+ protected boolean shouldScheduleNewService(ESBService service,
+ int pos) {
+ boolean ret=false;
+
+ for (int i=0; ret == false && i < pos; i++) {
+ ESBAction action=service.getActions().get(i);
+
+ if (action.isSessionBased() && !action.isSessionType()) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj.getSource().getObject() instanceof AbstractStatefulESBAction &&
+ (context.getParent() instanceof ESBService ||
+ ((AbstractStatefulESBAction)mobj.getSource().getObject()).getService() != null)
&&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the supplied model object from the
+ * supplied model. The model object representation must
+ * contain the necessary model specific to remove the
+ * object from the underlying model representation.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object to be deleted
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean delete(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+ ESBService service=getESBService(context, mobj);
+ ESBAction action=(ESBAction)mobj.getSource().getObject();
+
+ if (action != null && service != null) {
+ ret = service.getActions().remove(action);
+ }
+
+ return(ret);
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,553 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.IdentityUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation Interaction.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ConversationInteractionModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj,
+ ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ConversationInteraction interaction=(ConversationInteraction)mobj;
+
+ // Check if send or receive
+ if (InteractionUtil.isSend(interaction)) {
+
+ // Send
+ insertSend(context, esbModel, interaction, ref);
+
+ } else {
+ // Receive
+ insertReceive(context, esbModel, interaction, ref);
+ }
+
+ return(true);
+ }
+
+ protected void insertSend(ModelChangeContext context,
+ ESBLanguageModel esbModel, ConversationInteraction interaction,
+ ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+
+ SendMessageAction action=
+ new SendMessageAction(service);
+
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ setMessageType(action, interaction);
+
+ boolean f_subsequentInitiator=false;
+ boolean f_moveActions=false;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ int pos=getPosition(service, ref);
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
+ }
+ }
+
+ // Move actions if a subsequent initiator has been found
+ f_moveActions = f_subsequentInitiator;
+
+ service.addAction(action, pos);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action
&&
+ interaction.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)interaction.getEnclosingDefinition())));
+ }
+
+ if (interaction.getRequestLabel() != null) {
+
+ // Create new ESB service
+ ESBService respService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(respService);
+
+ action.setResponseDestination(respService.getCategory(),
+ respService.getName());
+
+ context.setParent(respService);
+
+ // Clear the sub-sequent initiator flag, as
+ // subsequent actions will be moved to new service
+ // anyway
+ f_subsequentInitiator = false;
+
+ } else if (interaction.getReplyToLabel() != null) {
+
+ if (interaction.getToRole() != null) {
+ action.setClientEPR(interaction.getToRole().getName());
+ } else {
+ action.setClientEPR("client");
+ }
+ }
+
+ // Check if subsequent initiator found, requiring
+ // a new service
+ if (f_subsequentInitiator) {
+
+ ESBService extraService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(extraService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(extraService.getCategory(),
+ extraService.getName(), false);
+
+ service.addAction(schedule, pos+1);
+
+ // Move pointer on, as now additional 'schedule' action
+ pos++;
+
+ context.setParent(extraService);
+ }
+
+ // Check if existing actions need to be moved
+ if (f_moveActions) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBService extraService=(ESBService)context.getParent();
+
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ extraService.addAction(act, -1);
+ }
+ }
+
+ // If not reply, then include the target service
+ // details
+ if (interaction.getReplyToLabel() == null &&
+ interaction.getToRole() != null &&
+ interaction.getToRole().getName() != null &&
+ interaction.getToRole().getName().length() > 0) {
+ String roleName=Character.toLowerCase(
+ interaction.getToRole().getName().charAt(0))+
+ interaction.getToRole().getName().substring(1);
+
+ action.setDestinationExpression(
+ InteractionUtil.getRoleServiceCategoryProperty(roleName),
+ InteractionUtil.getRoleServiceNameProperty(roleName));
+ }
+
+ if (interaction.getEnclosingDefinition() instanceof Conversation &&
+ interaction.getEnclosingDefinition().getModel()
+ instanceof ConversationModel) {
+
+ java.util.List<Identity> ids=((Conversation)
+ interaction.getEnclosingDefinition()).getIdentities();
+
+ java.util.List<IdentityLocator> locators=
+ ((ConversationModel)interaction.getEnclosingDefinition().
+ getModel()).getIdentityLocators();
+
+ IdentityUtil.defineIdentities(action.getPropertyElement(
+ SendMessageAction.IDENTITIES),
+ interaction.getMessageSignature(), ids, locators);
+ }
+ }
+
+ protected void insertReceive(ModelChangeContext context,
+ ESBLanguageModel esbModel, ConversationInteraction interaction,
+ ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+ ESBService endService=service;
+
+ int endPos=-1;
+ boolean f_subsequentInitiator=false;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ int pos=getPosition(service, ref);
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
+ }
+ }
+
+ endPos = pos;
+
+ // Check if receive needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService recvService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(recvService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(recvService.getCategory(),
+ recvService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(recvService);
+
+ endService = recvService;
+ endPos = 0;
+ }
+
+ ReceiveMessageAction action=
+ new ReceiveMessageAction(endService);
+
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ setMessageType(action, interaction);
+
+ endService.addAction(action, endPos);
+
+ if (endService.getFirstSessionBasedAction() == action &&
+ interaction.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)interaction.getEnclosingDefinition())));
+ }
+
+ // Check if subsequent initiator found, requiring
+ // a new service
+ if (f_subsequentInitiator) {
+
+ ESBService extraService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(endService.getCategory(),
+ endService.getName()));
+
+ esbModel.addService(extraService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(endService);
+
+ schedule.setDestination(extraService.getCategory(),
+ extraService.getName(), false);
+
+ endService.addAction(schedule, endPos+1);
+
+ // Move pointer on, as now additional 'schedule' action
+ pos++;
+
+ context.setParent(extraService);
+
+ endService = extraService;
+ endPos = -1;
+ }
+
+ // Check if existing actions need to be moved
+ if (pos != -1 && service != endService) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ endService.addAction(act, -1);
+ }
+ }
+
+ // If not a response, then add to the gateway
+ if (interaction.getReplyToLabel() == null) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ java.util.List<MessageSignature> mtypes=
+ new java.util.Vector<MessageSignature>();
+ mtypes.add(interaction.getMessageSignature());
+
+ mra.addRoute(endService.getCategory(),
+ endService.getName(),
+ service.isRoot(), mtypes);
+ }
+ }
+
+ // Set client EPR
+ if (interaction.getFromRole() != null) {
+ action.setClientEPR(interaction.getFromRole().getName());
+ } else {
+ action.setClientEPR("client");
+ }
+ }
+
+ if (interaction.getEnclosingDefinition() instanceof Conversation &&
+ interaction.getEnclosingDefinition().getModel()
+ instanceof ConversationModel) {
+
+ java.util.List<Identity> ids=((Conversation)
+ interaction.getEnclosingDefinition()).getIdentities();
+
+ java.util.List<IdentityLocator> locators=
+ ((ConversationModel)interaction.getEnclosingDefinition().
+ getModel()).getIdentityLocators();
+
+ IdentityUtil.defineIdentities(action.getPropertyElement(
+ SendMessageAction.IDENTITIES),
+ interaction.getMessageSignature(), ids, locators);
+ }
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof ConversationInteraction &&
+ toObj instanceof ConversationInteraction &&
+ context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
+ ConversationInteraction toInteraction=(ConversationInteraction)toObj;
+ ESBService service=(ESBService)context.getParent();
+
+ // Get action from 'toInteraction'
+ if (toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getRouteElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ if (interaction.getMessageSignature().getTypes().size() == 1) {
+ TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+
+ // TODO: Search for an implementation associated with
+ // the type reference, so that the type can be
+ // abstract - possibly have the required message type
+ // notation as part of the context, so that if multiple
+ // implementations found, then can select e.g. XML or
+ // Java as message type representation.
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,181 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ConversationModelChangeRule extends AbstractModelChangeRule {
+
+ private static final String NAME_SUFFIX = "_main";
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Conversation &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ Conversation conv=(Conversation)mobj;
+
+ String namespace=((Model)conv.getModel()).
+ getNamespace().getName();
+
+ String category=ConversationUtil.getServiceCategory(conv);
+
+ String name=ConversationUtil.getServiceName(conv);
+
+ String sdname="";
+
+ // Check if root conversation
+ if (conv.getParent() instanceof Model) {
+
+ // Register gateway service
+ DefaultESBService gateway=new DefaultESBService(esbModel,
+ category, name);
+
+ MessageRouterAction mra=new MessageRouterAction(gateway);
+
+ // Construct service description name
+ if (namespace != null) {
+ sdname = "{"+namespace+"}";
+ }
+
+ sdname += conv.getModelName().getName()+"-"+
+ conv.getModelName().getLocatedRole().getName();
+
+ mra.setServiceDescriptionName(sdname);
+
+ gateway.addAction(mra, -1);
+
+ esbModel.addService(gateway);
+
+ name += NAME_SUFFIX;
+ }
+
+ // Create new ESB service
+ ESBService service=esbModel.createService(category, name);
+
+ esbModel.addService(service);
+
+ // Create 'CreateSession' activity
+ CreateSessionAction csa=new CreateSessionAction(service);
+
+ // Check if root conversation
+ if (conv.getParent() instanceof Model) {
+ csa.setRoot(true);
+
+ String ctype=null;
+
+ // Check if conversation has a 'conforms to' reference
+ if (conv.getConformsTo().size() > 0) {
+ // Set conversation type based on first 'conforms to'
+ // reference
+ ConformanceReference cref=conv.getConformsTo().get(0);
+
+ ctype = cref.getNamespace()+"."+
+ cref.getLocalpart()+"@"+
+ cref.getLocatedRole();
+ } else {
+ // Set conversation type based on conversation
+ // namespace and name
+ ctype = namespace+"."+
+ conv.getModelName().getName()+"@"+
+ conv.getModelName().getLocatedRole().getName();
+ }
+
+ if (ctype != null) {
+ csa.setConversationType(ctype);
+ }
+ }
+
+ csa.setServiceDescriptionName(sdname);
+ csa.setBusinessObjectType(ConversationUtil.getBusinessObjectType(conv));
+
+ service.addAction(csa, -1);
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=conv.getBlock().getContents();
+
+ context.setParent(service);
+
+ for (int i=0; i < acts.size(); i++) {
+ context.insert(model, acts.get(i), null);
+ }
+
+ return(true);
+ }
+
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,416 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the If grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class IfModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof If &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ If ifElem=(If)mobj;
+
+ int pos=getPosition(service, ref);
+
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ // Check if should be an 'if' or a 'switch' action
+ if (ifElem.getRoles().contains(context.getRole())) {
+
+ insertIf(context, model, service, ifElem, joinService, pos);
+ } else {
+ insertSwitch(context, model, service, ifElem, joinService, pos);
+ }
+
+
+ context.setParent(joinService);
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ protected void insertIf(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // If action, because the role is a decision maker
+ IfAction ifAction=new IfAction(service);
+
+ service.addAction(ifAction, pos);
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
+ subService.getCategory(), subService.getName(),
+ immediate, null, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ if (ifElem.getElseBlock() != null) {
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath(IfAction.ELSE,
+ subService.getCategory(), subService.getName(),
+ immediate, null, -1);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ if (service.getFirstSessionBasedAction() == ifAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ protected void insertSwitch(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // Check if 'when' needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService switchService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(switchService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(switchService.getCategory(),
+ switchService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(switchService);
+
+ service = switchService;
+ pos = -1;
+ }
+
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, pos);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ }
+
+ if (ifElem.getElseBlock() != null) {
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(ifElem.getElseBlock());
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, -1);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ }
+
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
+ }
+
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Language Model to
+ * Conversation Model.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class LanguageToConversationModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationModel &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ConversationModel cm=(ConversationModel)mobj;
+
+ if (cm.getConversation() != null) {
+ context.insert(model, cm.getConversation(), null);
+ }
+
+ return(true);
+ }
+
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the MessageSignature.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class MessageSignatureModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof MessageSignature &&
+ toObj instanceof MessageSignature &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ MessageSignature fromMS=(MessageSignature)fromObj;
+ MessageSignature toMS=(MessageSignature)toObj;
+ ConversationInteraction toInteraction=null;
+ ConversationInteraction fromInteraction=null;
+
+ if (toMS != null &&
+ toMS.getParent() instanceof ConversationInteraction) {
+ toInteraction = (ConversationInteraction)toMS.getParent();
+ }
+
+ if (fromMS != null &&
+ fromMS.getParent() instanceof ConversationInteraction) {
+ fromInteraction = (ConversationInteraction)fromMS.getParent();
+ }
+
+ // Get action from 'toInteraction'
+ if (toInteraction != null &&
+ toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ // Update operation
+ setOperation(ma, fromInteraction);
+
+ ESBService service = ma.getService();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getRouteElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ if (interaction.getMessageSignature().getTypes().size() == 1) {
+ TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+
+ // TODO: Search for an implementation associated with
+ // the type reference, so that the type can be
+ // abstract - possibly have the required message type
+ // notation as part of the context, so that if multiple
+ // implementations found, then can select e.g. XML or
+ // Java as message type representation.
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+
+ protected void setOperation(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Parallel grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ParallelModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Parallel &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ Parallel parallel=(Parallel)mobj;
+
+ int pos=getPosition(service, ref);
+
+ // Create the join service
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ // Create and configure the parallel action
+ ParallelAction parAction=new ParallelAction(service);
+
+ service.addAction(parAction, pos);
+
+ for (int i=0; i < parallel.getBlocks().size(); i++) {
+ Block b=parallel.getBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < b.getContents().size(); j++) {
+ context.insert(model, b.getContents().get(j), null);
+ }
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ parallel.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)parallel.getEnclosingDefinition())));
+ }
+
+ boolean immediate=true;
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to get lookahead analyser");
+ } else {
+ java.util.Iterator<Interaction> iter=
+ la.getInteractions(b, true).iterator();
+
+ while (immediate && iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ // If interaction is a receive, then immediate
+ // invocation will be false
+ immediate = InteractionUtil.isSend(interaction);
+ }
+ }
+
+ parAction.addPath(subService.getCategory(),
+ subService.getName(), immediate, false, i);
+ }
+
+ context.setParent(joinService);
+
+ parAction.addPath(joinService.getCategory(),
+ joinService.getName(), false, true, -1);
+
+ // Check if business object type needs to be specified
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == parAction
&&
+ parallel.getEnclosingDefinition() instanceof Conversation) {
+ parAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)parallel.getEnclosingDefinition())));
+ }
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Run composition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class RunModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Run &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ Run run=(Run)mobj;
+
+ int pos=getPosition(service, ref);
+
+ PerformAction action=new PerformAction(service);
+
+ service.addAction(action, pos);
+
+ String category=ConversationUtil.getServiceCategory(run.getDefinition());
+ String name=ConversationUtil.getServiceName(run.getDefinition());
+
+ action.setDestination(category, name);
+
+ // Check if business object type needs to be specified
+ if (service.getFirstSessionBasedAction() == action &&
+ run.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)run.getEnclosingDefinition())));
+ }
+
+ // Create return service
+ ESBService returnService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(returnService);
+
+ context.setParent(returnService);
+
+ action.setReturnDestination(returnService.getCategory(),
+ returnService.getName());
+
+ // If reference provided, then move subsequent activities
+ // to the 'return service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ returnService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof Run &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the supplied model object from the
+ * supplied model. The model object representation must
+ * contain the necessary model specific to remove the
+ * object from the underlying model representation.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object to be deleted
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean delete(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+ ESBService service=getESBService(context, mobj);
+ ESBAction action=(ESBAction)mobj.getSource().getObject();
+
+ int pos=getPosition(service, mobj);
+
+ if (action instanceof PerformAction && pos != -1) {
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ PerformAction perform=(PerformAction)action;
+
+ schedule.setDestination(perform.getPropertyValue(PerformAction.RETURN_SERVICE_CATEGORY),
+ perform.getPropertyValue(PerformAction.RETURN_SERVICE_NAME), true);
+
+ service.addAction(schedule, pos);
+
+ ret = super.delete(context, model, mobj);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+//import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Spawn composition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class SpawnModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Spawn &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+ Spawn spawn=(Spawn)mobj;
+
+ int pos=getPosition(service, ref);
+
+ PerformAction action=new PerformAction(service);
+
+ service.addAction(action, pos);
+
+ String category=ConversationUtil.getServiceCategory(spawn.getDefinition());
+ String name=ConversationUtil.getServiceName(spawn.getDefinition());
+
+ action.setDestination(category, name);
+
+ // Check if business object type needs to be specified
+ if (service.getFirstSessionBasedAction() == action &&
+ spawn.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)spawn.getEnclosingDefinition())));
+ }
+
+ return(true);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof Spawn &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ //private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,172 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Type Reference.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class TypeReferenceModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof TypeReference &&
+ toObj instanceof TypeReference &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ TypeReference fromTypeRef=(TypeReference)fromObj;
+ TypeReference toTypeRef=(TypeReference)toObj;
+ ConversationInteraction toInteraction=null;
+ ConversationInteraction fromInteraction=null;
+
+ if (toTypeRef != null && toTypeRef.getParent() instanceof MessageSignature
&&
+ toTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+ toInteraction = (ConversationInteraction)toTypeRef.getParent().getParent();
+ }
+
+ if (fromTypeRef != null && fromTypeRef.getParent() instanceof MessageSignature
&&
+ fromTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+ fromInteraction = (ConversationInteraction)fromTypeRef.getParent().getParent();
+ }
+
+ // Get action from 'toInteraction'
+ if (toInteraction != null &&
+ toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ ESBService service = ma.getService();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getRouteElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ if (interaction.getMessageSignature().getTypes().size() == 1) {
+ TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+
+ // TODO: Search for an implementation associated with
+ // the type reference, so that the type can be
+ // abstract - possibly have the required message type
+ // notation as part of the context, so that if multiple
+ // implementations found, then can select e.g. XML or
+ // Java as message type representation.
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,322 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the When grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class WhenModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof When &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ When when=(When)mobj;
+
+ int pos=getPosition(service, ref);
+
+ // Create join service
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ // Check if context role is decision maker
+ if (when.getRoles().contains(context.getRole())) {
+
+ insertWhen(context, model, service,
+ when, joinService, pos);
+ } else {
+ insertSwitch(context, model, service,
+ when, joinService, pos);
+ }
+
+ context.setParent(joinService);
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ protected void insertWhen(ModelChangeContext context,
+ Model model, ESBService service,
+ When when, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ WhenAction action=new WhenAction(service);
+
+ service.addAction(action, pos);
+
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock b=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < b.getContents().size(); j++) {
+ context.insert(model, b.getContents().get(j), null);
+ }
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+
+ action.addPath(subService.getCategory(),
+ subService.getName(), i);
+ }
+
+ if (service.getFirstSessionBasedAction() == action &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+ }
+
+ protected void insertSwitch(ModelChangeContext context,
+ Model model, ESBService service,
+ When when, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // Check if 'when' needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService switchService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(switchService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(switchService.getCategory(),
+ switchService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(switchService);
+
+ service = switchService;
+ pos = -1;
+ }
+
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, pos);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ }
+
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
+ }
+
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,246 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the While repetition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class WhileModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof While &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ ESBService original=service;
+ While whileElem=(While)mobj;
+
+ int pos=getPosition(service, ref);
+
+ // Check if action needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ ESBService whileService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(whileService);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ // 'immediate' flag set depending on whether the role
+ // is an initiator of the while. If not, then the
+ // immediate flag is false, which means the loop will be
+ // evaluated based on the next received message
+ schedule.setDestination(whileService.getCategory(),
+ whileService.getName(),
+ whileElem.getRoles().contains(context.getRole()));
+ service.addAction(schedule, pos);
+
+ context.setParent(whileService);
+
+ service = whileService;
+ }
+
+ WhileAction action=new WhileAction(service);
+
+ service.addAction(action, -1);
+
+ // Check if business object type needs to be specified
+ if (service.getFirstSessionBasedAction() == action &&
+ whileElem.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)whileElem.getEnclosingDefinition())));
+ }
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ // Configure the while loop service
+ context.setParent(subService);
+
+ for (int j=0; j < whileElem.getBlock().getContents().size(); j++) {
+ context.insert(model, whileElem.getBlock().getContents().get(j), null);
+ }
+
+ // Need to insert a 'ScheduleStateAction' to return back
+ // to the 'WhileAction', to re-evaluate the expression
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ // 'immediate' flag set depending on whether the role
+ // is an initiator of the while. If not, then the
+ // immediate flag is false, which means the loop will be
+ // evaluated based on the next received message
+ schedule.setDestination(service.getCategory(),
+ service.getName(),
+ whileElem.getRoles().contains(context.getRole()));
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ // Check if business object type needs to be specified
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule
&&
+ whileElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)whileElem.getEnclosingDefinition())));
+ }
+
+ // Check whether message types need to be defined in
+ // place of an expression
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ // Check if context role is NOT the decision maker
+ if (whileElem.getRoles().contains(context.getRole()) == false) {
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(whileElem.getBlock());
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+
+ }
+
+ action.addPath(subService.getCategory(),
+ subService.getName(), false, messageTypes, -1);
+
+ // Create exit service
+ ESBService exitService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(exitService);
+
+ context.setParent(exitService);
+
+ action.addPath(exitService.getCategory(),
+ exitService.getName(), true,
+ new java.util.Vector<MessageSignature>(), -1);
+
+ // If reference provided, then move subsequent activities
+ // to the 'exit service'
+ if (pos != -1) {
+ for (int i=pos+1; i < original.getActions().size();) {
+ ESBAction act=original.getActions().get(i);
+ original.getActions().remove(i);
+
+ exitService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,1847 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ConversationInteractionModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class ConversationInteractionModelChangeRuleTest extends TestCase {
-
- public void testInsertFirstReceiveAction() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setToRole(role);
- conv.getBlock().getContents().add(mobj);
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 1) {
- fail("One route expected: "+mra.getNumberOfRoutes());
- }
- }
-
- public void testInsertFirstReceiveAfterCreateSessionAction() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add 'create session' action
- TestESBAction act=new TestESBAction();
- act.setCreateSession(true);
- service.addAction(act, -1);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setToRole(role);
- conv.getBlock().getContents().add(mobj);
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof TestESBAction) == false) {
- fail("Action was not TestESBAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(1);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 1) {
- fail("One route expected: "+mra.getNumberOfRoutes());
- }
- }
-
- public void testInsertSecondReceiveAction() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setToRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.IMMEDIATE) != null) {
- fail("Schedule should not be immediate");
- }
-
- if (newService.getActions().size() != 1) {
- fail("Expecting 1 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction:
"+newService.getActions().get(0));
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)newService.getActions().get(0);
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 2) {
- fail("Two routes expected: "+mra.getNumberOfRoutes());
- }
- }
-
-
- public void testInsertMiddleReceiveBetweenTwoReceives() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setToRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- ((TestESBService)newService).setSessionBased(true);
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- // Check actions
- if (newService.getActions().size() != 1) {
- fail("Expecting 1 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
- }
-
- ReceiveMessageAction recv2=(ReceiveMessageAction)
- newService.getActions().get(0);
-
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+recv2.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- recv2.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // Now second service identified, add new receive
- // action to ensure that third service inserted in the
- // middle
- ConversationInteraction mobj3=new ConversationInteraction();
- mobj3.setToRole(role);
- conv.getBlock().getContents().add(mobj3);
-
- MessageSignature msig3=new MessageSignature();
- mobj3.setMessageSignature(msig3);
-
- TypeReference ref3=new TypeReference();
- ref3.setNamespace("ns");
- ref3.setLocalpart("lp3");
-
- msig3.getTypes().add(ref3);
-
- // Insert into position 1, which should be after first
- // receive
-
- // TODO: Need to pass representation of last interaction
- if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
- fail("Failed to insert 3");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- // TODO: Need to check if new service has been inserted
- // in the middle of the previously inserted interactions
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Now Expecting 2 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
- }
-
- if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction:
"+newService.getActions().get(1));
- }
-
- ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
-
- ESBService newService2=model.getService(ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME));
-
- if (newService2 == null) {
- fail("Failed to find final service");
- }
-
- if (newService2.getActions().size() != 1) {
- fail("Only expecting one action: "+newService2.getActions().size());
- }
-
- ReceiveMessageAction recv4=(ReceiveMessageAction)
- newService2.getActions().get(0);
-
- String mtype4=InteractionUtil.getTypeString(ref2);
-
- if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
- fail("Message type '"+recv4.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype4);
- }
-
-
- ReceiveMessageAction recv3=(ReceiveMessageAction)
- newService.getActions().get(0);
-
- String mtype3=InteractionUtil.getTypeString(ref3);
-
- if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
- fail("Message type '"+recv3.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype3);
- }
- }
-
- public void testInsertMiddleSendBetweenTwoReceives() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setToRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- ((TestESBService)newService).setSessionBased(true);
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- // Check actions
- if (newService.getActions().size() != 1) {
- fail("Expecting 1 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
- }
-
- ReceiveMessageAction recv2=(ReceiveMessageAction)
- newService.getActions().get(0);
-
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+recv2.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- recv2.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // Now second service identified, add new receive
- // action to ensure that third service inserted in the
- // middle
- ConversationInteraction mobj3=new ConversationInteraction();
- mobj3.setFromRole(role);
- conv.getBlock().getContents().add(mobj3);
-
- MessageSignature msig3=new MessageSignature();
- mobj3.setMessageSignature(msig3);
-
- TypeReference ref3=new TypeReference();
- ref3.setNamespace("ns");
- ref3.setLocalpart("lp3");
-
- msig3.getTypes().add(ref3);
-
- // Insert into position 1, which should be after first
- // receive
-
- // TODO: Need to pass representation of last interaction
- if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
- fail("Failed to insert 3");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- // TODO: Need to check if new service has been inserted
- // in the middle of the previously inserted interactions
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Now Expecting 2 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action 1 was not SendMessageAction:
"+newService.getActions().get(0));
- }
-
- if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction:
"+newService.getActions().get(1));
- }
-
- ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
-
- ESBService newService2=model.getService(ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME));
-
- if (newService2 == null) {
- fail("Failed to find final service");
- }
-
- if (newService2.getActions().size() != 1) {
- fail("Only expecting one action: "+newService2.getActions().size());
- }
-
- if ((newService2.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Expecting ReceiveMessageAction, but got:
"+newService2.getActions().get(0));
- }
-
- ReceiveMessageAction recv4=(ReceiveMessageAction)
- newService2.getActions().get(0);
-
- String mtype4=InteractionUtil.getTypeString(ref2);
-
- if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
- fail("Message type '"+recv4.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype4);
- }
-
-
- SendMessageAction send3=(SendMessageAction)
- newService.getActions().get(0);
-
- String mtype3=InteractionUtil.getTypeString(ref3);
-
- if (send3.getPropertyValue("messageType").equals(mtype3)==false) {
- fail("Message type '"+send3.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype3);
- }
- }
-
- public void testInsertMiddleReceiveBetweenTwoSends() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setFromRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setFromRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
- fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- SendMessageAction send2=(SendMessageAction)
- service.getActions().get(1);
-
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (send2.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+send2.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- send2.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // Now second service identified, add new receive
- // action to ensure that third service inserted in the
- // middle
- ConversationInteraction mobj3=new ConversationInteraction();
- mobj3.setToRole(role);
- conv.getBlock().getContents().add(mobj3);
-
- MessageSignature msig3=new MessageSignature();
- mobj3.setMessageSignature(msig3);
-
- TypeReference ref3=new TypeReference();
- ref3.setNamespace("ns");
- ref3.setLocalpart("lp3");
-
- msig3.getTypes().add(ref3);
-
- // Insert into position 1, which should be after first
- // send
-
- // TODO: Need to pass representation of last interaction
- if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
- fail("Failed to insert 3");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Now Expecting 2 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
- }
-
- if ((newService.getActions().get(1) instanceof SendMessageAction) == false) {
- fail("Action 2 was not SendMessageAction:
"+newService.getActions().get(1));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- ReceiveMessageAction recv3=(ReceiveMessageAction)
- newService.getActions().get(0);
-
- String mtype3=InteractionUtil.getTypeString(ref3);
-
- if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
- fail("Message type '"+recv3.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype3);
- }
- }
-
- public void testInsertReceiveRequestAction() {
- String fromRoleName="role1";
- String toRoleName="role2";
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role fromRole=new Role();
- fromRole.setName(fromRoleName);
-
- Role toRole=new Role();
- toRole.setName(toRoleName);
-
- context.setRole(toRole);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(toRole);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(fromRole);
- mobj.setToRole(toRole);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setRequestLabel("reqLabel");
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
-
- if (action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR).equals(fromRoleName) ==
false) {
- fail("Client EPR
'"+action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR)+
- "' invalid, expecting: "+fromRoleName);
- }
- }
-
- public void testInsertFirstSendAction() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(role);
- conv.getBlock().getContents().add(mobj);
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
- }
-
- public void testInsertSendRequestAction() {
- String roleName="role1";
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName(roleName);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(role);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setRequestLabel("reqLabel");
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two service expected: "+model.getServices().size());
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- if (newService.getCategory().equals(action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
- }
-
- public void testInsertSendNotReplyAction() {
- String fromRoleName="role1";
- String toRoleName="role2";
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role fromRole=new Role();
- fromRole.setName(fromRoleName);
-
- Role toRole=new Role();
- toRole.setName(toRoleName);
-
- context.setRole(fromRole);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(fromRole);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(fromRole);
- mobj.setToRole(toRole);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setRequestLabel("reqLabel");
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two service expected: "+model.getServices().size());
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- if (action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION).
- equals(InteractionUtil.getRoleServiceCategoryProperty(toRoleName)) == false) {
- fail("Service category expression '"+
- action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION)+
- "' invalid, expecting: "+
- InteractionUtil.getRoleServiceCategoryProperty(toRoleName));
- }
-
- if (action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION).
- equals(InteractionUtil.getRoleServiceNameProperty(toRoleName)) == false) {
- fail("Service name expression '"+
- action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION)+
- "' invalid, expecting: "+
- InteractionUtil.getRoleServiceNameProperty(toRoleName));
- }
- }
-
- public void testInsertSendReplyAction() {
- String fromRoleName="role1";
- String toRoleName="role2";
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role fromRole=new Role();
- fromRole.setName(fromRoleName);
-
- Role toRole=new Role();
- toRole.setName(toRoleName);
-
- context.setRole(fromRole);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(fromRole);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(fromRole);
- mobj.setToRole(toRole);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setReplyToLabel("replyLabel");
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- if (action.getPropertyValue(SendMessageAction.CLIENT_EPR).equals(toRoleName) == false)
{
- fail("Client EPR
'"+action.getPropertyValue(SendMessageAction.CLIENT_EPR)+
- "' invalid, expecting: "+toRoleName);
- }
- }
-
- public void testChangeFirstReceiveAction() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setToRole(role);
- conv.getBlock().getContents().add(mobj);
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp1");
-
- msig.getTypes().add(ref);
-
- // Create ReceiveMessageAction
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
-
- java.util.List<Activity> activities=new java.util.Vector<Activity>();
- action.convert(activities, new DefaultConversionContext(null));
-
- if (activities.size() != 1) {
- fail("Expecting single interaction activity from ReceiveMessageAction:
"+activities.size());
- }
-
- if ((activities.get(0) instanceof ConversationInteraction) == false) {
- fail("Not conversation interaction");
- }
-
- ConversationInteraction recvci=(ConversationInteraction)activities.get(0);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- // Change local part
- ref.setLocalpart("lp2");
-
- if (rule.update(context, model, mobj, recvci) == false) {
- fail("Failed to update");
- }
-
- // Re-check the message type, to make sure has been updated
- mtype = InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 1) {
- fail("One route expected: "+mra.getNumberOfRoutes());
- }
-
- org.w3c.dom.Element route=mra.getRouteElement(0);
-
- org.w3c.dom.NodeList
mesgs=route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- if (mesgs.getLength() != 1) {
- fail("Too many route message elements: "+mesgs.getLength());
- }
-
- org.w3c.dom.Element mesg=(org.w3c.dom.Element)mesgs.item(0);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).equals(mtype) == false) {
- fail("Route message type has not been updated");
- }
- }
-
- public void testDeleteMiddleReceiveBetweenTwoActions() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- TestESBAction act2=new TestESBAction();
- ((ESBService)context.getParent()).addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- ((TestESBService)newService).setSessionBased(true);
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Expecting 2 actions: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
- }
-
- if (newService.getActions().get(1) != act2) {
- fail("Action 2 was not 2nd test ESB action:
"+newService.getActions().get(1));
- }
-
- ReceiveMessageAction recv=(ReceiveMessageAction)
- newService.getActions().get(0);
-
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- recv.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete receive");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- // TODO: Need to check if new service has been inserted
- // in the middle of the previously inserted interactions
-
- // Check actions
- if (newService.getActions().size() != 1) {
- fail("Now Expecting 1 action: "+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Action 1 was not 2nd test ESB action:
"+newService.getActions().get(0));
- }
- }
-
- public void testDeleteMiddleSendBetweenTwoActions() {
- ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setFromRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- TestESBAction act2=new TestESBAction();
- ((ESBService)context.getParent()).addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 3) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
- fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
- }
-
- if (service.getActions().get(2) != act2) {
- fail("Action 3 was not 2nd test ESB action: "+service.getActions().get(2));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
-
- SendMessageAction send=(SendMessageAction)
- service.getActions().get(1);
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- send.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete send");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if (service.getActions().get(1) != act2) {
- fail("Action 2 was not 2nd test ESB action: "+service.getActions().get(1));
- }
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,1069 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.IfModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class IfModelChangeRuleTest extends TestCase {
-
- public void testInsertIfAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (ifService == null && iter.hasNext()) {
- ifService = iter.next();
- if (ifService == service) {
- ifService = null;
- }
- }
-
- IfAction action=(IfAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 1) {
- fail("Only one path child expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("if") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(ifService.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+ifService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(ifService.getName()) == false)
{
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+ifService.getName());
- }
- }
-
- public void testInsertIfActionWithSubsequentActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || join == null) && iter.hasNext()) {
- ESBService s = iter.next();
- if (s != service) {
- if (ifService == null) {
- ifService = s;
- } else if (join == null) {
- join = s;
- }
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertIfActionWithPrecedingActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof IfAction) == false) {
- fail("Action 2 was not IfAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || join == null) && iter.hasNext()) {
- ESBService s = iter.next();
- if (s != service) {
- if (ifService == null) {
- ifService = s;
- } else if (join == null) {
- join = s;
- }
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertIfElseIfAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService elseIfService1=null;
- ESBService elseIfService2=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || elseIfService1 == null ||
- elseIfService2 == null || join==null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- ifService = serv;
- }
- if (serv.getName().endsWith("__2")) {
- elseIfService1 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- elseIfService2 = serv;
- }
- }
-
- IfAction action=(IfAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("if") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(ifService.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+ifService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(ifService.getName()) == false)
{
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+ifService.getName());
- }
-
- if (ifService.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+ifService.getActions().size());
- }
-
- if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+ifService.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("elseif") == false) {
- fail("ElseIf expected but got: "+elem.getNodeName());
- }
-
- if
(elem.getAttribute("service-category").equals(elseIfService1.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+elseIfService1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(elseIfService1.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+elseIfService1.getName());
- }
-
- if (elseIfService1.getActions().size() != 1) {
- fail("Path(2) does not have 1 action:
"+elseIfService1.getActions().size());
- }
-
- if ((elseIfService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+elseIfService1.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)elseIfService1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("elseif") == false) {
- fail("ElseIf(2) expected but got: "+elem.getNodeName());
- }
-
- if
(elem.getAttribute("service-category").equals(elseIfService2.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+elseIfService2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(elseIfService2.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+elseIfService2.getName());
- }
-
- if (elseIfService2.getActions().size() != 1) {
- fail("Path(3) does not have 1 action:
"+elseIfService2.getActions().size());
- }
-
- if ((elseIfService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+elseIfService2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)elseIfService2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertIfElseAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- Block b1=new Block();
- mobj.setElseBlock(b1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService elseService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || elseService == null ||
- join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- ifService = serv;
- }
- if (serv.getName().endsWith("__2")) {
- elseService = serv;
- }
- }
-
- IfAction action=(IfAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("if") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(ifService.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+ifService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(ifService.getName()) == false)
{
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+ifService.getName());
- }
-
- if (ifService.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+ifService.getActions().size());
- }
-
- if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+ifService.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("else") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(elseService.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+elseService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(elseService.getName()) == false)
{
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+elseService.getName());
- }
-
- if (elseService.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+elseService.getActions().size());
- }
-
- if ((elseService.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+elseService.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)ifService.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- }
-
- public void testInsertSwitchAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService switchService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (switchService == null && iter.hasNext()) {
- switchService = iter.next();
- if (switchService == service) {
- switchService = null;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 1) {
- fail("Only one path child expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Switch expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(switchService.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+switchService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(switchService.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+switchService.getName());
- }
- }
-
- public void testInsertSwitchMultipleCaseAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- Block b1=new Block();
- mobj.setElseBlock(b1);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- ESBService caseService1=null;
- ESBService caseService2=null;
- ESBService caseService3=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((caseService1 == null || caseService2 == null ||
- caseService3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- caseService1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- caseService2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- caseService3 = serv;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService1.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+caseService1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService1.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService1.getName());
- }
-
- if (caseService1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
- }
-
- if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService2.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+caseService2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService2.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService2.getName());
- }
-
- if (caseService2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
- }
-
- if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService3.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+caseService3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService3.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService3.getName());
- }
-
- if (caseService3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
- }
-
- if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertSwitchActionWithSubsequentActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService switchService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((switchService == null || join == null) && iter.hasNext()) {
- ESBService s = iter.next();
- if (s != service) {
- if (switchService == null) {
- switchService = s;
- } else if (join == null) {
- join = s;
- }
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertSwitchActionWithPrecedingActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("First action not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
-
- ESBService addedService=model.getService(
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
-
- if (addedService == null) {
- fail("Failed to find service '"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"'
'"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
- }
-
- if (addedService.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (join == null && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action");
- }
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,624 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ParallelModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.analysis.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class ParallelModelChangeRuleTest extends TestCase {
-
- public void testInsertParallelAction() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Parallel mobj=new Parallel();
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- Block cb2=new Block();
- mobj.getBlocks().add(cb2);
-
- Block cb3=new Block();
- mobj.getBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null || s3 == null ||
- join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 4) {
- fail("Four path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(1) immediate not set");
- }
-
- if (s1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+s1.getActions().size());
- }
-
- if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(2) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(2) immediate not set");
- }
-
- if (s2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+s2.getActions().size());
- }
-
- if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(3) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s3.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s3.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(3) immediate not set");
- }
-
- if (s3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+s3.getActions().size());
- }
-
- if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(3);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
- }
-
- public void testInsertParallelActionWithImmediateFalse() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
-
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- Parallel mobj=new Parallel();
- conv.getBlock().getContents().add(mobj);
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- cb1.getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("path(1) should not be immediate");
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
- }
-
- public void testInsertParallelActionWithImmediateTrue() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setFromRole(role);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- Parallel mobj=new Parallel();
- conv.getBlock().getContents().add(mobj);
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- cb1.getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(1) should be immediate");
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
- }
-
- public void testInsertParallelMiddleAction() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Parallel mobj=new Parallel();
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- Block cb2=new Block();
- mobj.getBlocks().add(cb2);
-
- Block cb3=new Block();
- mobj.getBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action was not test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (join == null && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(1);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 4) {
- fail("Four path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(3);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
-
- if (join.getActions().size() != 1) {
- fail("Expecting 1 join action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Action was not test ESB action 2: "+join.getActions().get(0));
- }
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,471 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.RunModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class RunModelChangeRuleTest extends TestCase {
-
- public void testInsertPerformAction() {
- String runName="subconv";
-
- RunModelChangeRule rule=new RunModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Run mobj=new Run();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(0);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check details
- if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- if (newService.getCategory().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
- fail("Perform return service category '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)) == false) {
- fail("Perform return service name '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
- }
-
- public void testInsertPerformActionMiddle() {
- String runName="subconv";
-
- RunModelChangeRule rule=new RunModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Run mobj=new Run();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check details
- if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- if (newService.getCategory().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
- fail("Perform return service category '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)) == false) {
- fail("Perform return service name '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
-
- if (newService.getActions().size() != 1) {
- fail("Return service should have 1 action:
"+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Expecting test ESB action 2: "+newService.getActions().get(0));
- }
-
- }
- public void testDeletePerformActionMiddle() {
- String runName="subconv";
-
- RunModelChangeRule rule=new RunModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Run mobj=new Run();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- TestESBAction act2=new TestESBAction();
- ((ESBService)context.getParent()).addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check details
- if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- if (newService.getCategory().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
- fail("Perform return service category '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)) == false) {
- fail("Perform return service name '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
-
- if (newService.getActions().size() != 1) {
- fail("Return service should have 1 action:
"+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Expecting test ESB action 2: "+newService.getActions().get(0));
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- action.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete spawn");
- }
-
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction ssa=(ScheduleStateAction)service.getActions().get(1);
-
- if
(ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY).equals(newService.getCategory()) ==
false) {
- fail("Category not correct
'"+ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY)+
- "' expecting: "+newService.getCategory());
- }
-
- if (ssa.getPropertyValue(PerformAction.SERVICE_NAME).equals(newService.getName()) ==
false) {
- fail("Name not correct
'"+ssa.getPropertyValue(PerformAction.SERVICE_NAME)+
- "' expecting: "+newService.getName());
- }
-
- if (newService.getActions().size() != 1) {
- fail("Return service should have 1 action:
"+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Expecting test ESB action 2: "+newService.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,346 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.RunModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.SpawnModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class SpawnModelChangeRuleTest extends TestCase {
-
- public void testInsertPerformAction() {
- String runName="subconv";
-
- SpawnModelChangeRule rule=new SpawnModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Spawn mobj=new Spawn();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(0);
-
- // Check details
- if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- }
-
- public void testInsertPerformActionMiddle() {
- String runName="subconv";
-
- SpawnModelChangeRule rule=new SpawnModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Spawn mobj=new Spawn();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 3) {
- fail("Expecting 3 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (service.getActions().get(2) != act2) {
- fail("Expecting test ESB action 2: "+service.getActions().get(2));
- }
-
- if (model.getServices().size() != 1) {
- fail("One services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- // Check details
- if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- }
-
- public void testDeletePerformActionMiddle() {
- String runName="subconv";
-
- SpawnModelChangeRule rule=new SpawnModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Spawn mobj=new Spawn();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 3) {
- fail("Expecting 3 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (service.getActions().get(2) != act2) {
- fail("Expecting test ESB action 2: "+service.getActions().get(2));
- }
-
- if (model.getServices().size() != 1) {
- fail("One services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- // Check details
- if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- action.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete spawn");
- }
-
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if (service.getActions().get(1) != act2) {
- fail("Expecting test ESB action 2: "+service.getActions().get(1));
- }
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,903 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhenModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class WhenModelChangeRuleTest extends TestCase {
-
- public void testInsertWhenAction() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- When mobj=new When();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhenAction) == false) {
- fail("Action was not WhenAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null ||
- s3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- WhenAction action=(WhenAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("when") == false) {
- fail("when(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (s1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+s1.getActions().size());
- }
-
- if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("when") == false) {
- fail("when(2) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
-
- if (s2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+s2.getActions().size());
- }
-
- if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("when") == false) {
- fail("when(3) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s3.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s3.getName());
- }
-
- if (s3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+s3.getActions().size());
- }
-
- if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertWhenActionWithSubsequentActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- When mobj=new When();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhenAction) == false) {
- fail("Action was not WhenAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null ||
- s3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
-
- public void testInsertWhenActionWithPrecedingActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- When mobj=new When();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof WhenAction) == false) {
- fail("Action 2 was not WhenAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null ||
- s3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action 2");
- }
- }
-
- public void testInsertSwitchAction() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService switchService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (switchService == null && iter.hasNext()) {
- switchService = iter.next();
- if (switchService == service) {
- switchService = null;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 1) {
- fail("Only one path child expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Switch expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(switchService.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+switchService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(switchService.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+switchService.getName());
- }
- }
-
- public void testInsertSwitchMultipleCaseAction() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- ESBService caseService1=null;
- ESBService caseService2=null;
- ESBService caseService3=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((caseService1 == null || caseService2 == null ||
- caseService3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- caseService1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- caseService2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- caseService3 = serv;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Case expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService1.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+caseService1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService1.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService1.getName());
- }
-
- if (caseService1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
- }
-
- if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Case expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService2.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+caseService2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService2.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService2.getName());
- }
-
- if (caseService2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
- }
-
- if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService3.getCategory())
== false) {
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+caseService3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService3.getName()) ==
false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService3.getName());
- }
-
- if (caseService3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
- }
-
- if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertSwitchActionWithSubsequentActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- ESBService caseService1=null;
- ESBService caseService2=null;
- ESBService caseService3=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((caseService1 == null || caseService2 == null ||
- caseService3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- caseService1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- caseService2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- caseService3 = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertSwitchActionWithPrecedingActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("First action not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
-
- ESBService addedService=model.getService(
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
-
- if (addedService == null) {
- fail("Failed to find service '"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"'
'"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
- }
-
- if (addedService.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 6) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (join == null && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action");
- }
- }
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java 2009-01-20
22:16:58 UTC (rev 466)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -1,706 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhileModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.analysis.TestLookaheadAnalyser;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class WhileModelChangeRuleTest extends TestCase {
-
- public void testInsertWhileActionInitiator() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s2 = serv;
- }
- }
-
- WhileAction action=(WhileAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 0) {
- fail("Should have no message types: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileActionRecipient() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getBlock().getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s2 = serv;
- }
- }
-
- WhileAction action=(WhileAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 1) {
- fail("Should have single message type: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileActionRecipientNoRecvLookahead() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setFromRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getBlock().getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s2 = serv;
- }
- }
-
- WhileAction action=(WhileAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 0) {
- fail("Should have no message type: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileNotFirstSessionAction() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Make session based service
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction whileSchedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService whileService=null;
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null || whileService == null) &&
- iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- whileService = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- }
-
- if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(whileService.getCategory()) == false) {
- fail("While schedule action category '"+
- whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+
- "' not expected: "+whileService.getCategory());
- }
-
- if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(whileService.getName()) == false) {
- fail("While schedule action service name '"+
- whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+
- "' not expected: "+whileService.getName());
- }
-
- if (whileService.getActions().size() != 1) {
- fail("Expecting 1 action: "+whileService.getActions().size());
- }
-
- if ((whileService.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+whileService.getActions().get(0));
- }
-
- WhileAction action=(WhileAction)whileService.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 0) {
- fail("Should have no message types: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
- fail("Service category
'"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileMiddleAction() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Make session based service
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction whileSchedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService whileService=null;
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null || whileService == null) &&
- iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- whileService = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- }
-
- if (s2.getActions().size() != 1) {
- fail("Expecting 1 action in exit service: "+s2.getActions().size());
- }
-
- if (s2.getActions().get(0) != act2) {
- fail("Action in exit is not test ESB action: "+s2.getActions().get(0));
- }
- }
-}
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,1847 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationInteractionModelChangeRule;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class ConversationInteractionModelChangeRuleTest extends TestCase {
+
+ public void testInsertFirstReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+ public void testInsertFirstReceiveAfterCreateSessionAction() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add 'create session' action
+ TestESBAction act=new TestESBAction();
+ act.setCreateSession(true);
+ service.addAction(act, -1);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof TestESBAction) == false) {
+ fail("Action was not TestESBAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(1);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+ public void testInsertSecondReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setToRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.IMMEDIATE) != null) {
+ fail("Schedule should not be immediate");
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction:
"+newService.getActions().get(0));
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)newService.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 2) {
+ fail("Two routes expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+
+ public void testInsertMiddleReceiveBetweenTwoReceives() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setToRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ ((TestESBService)newService).setSessionBased(true);
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
+ }
+
+ ReceiveMessageAction recv2=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+recv2.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ recv2.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // Now second service identified, add new receive
+ // action to ensure that third service inserted in the
+ // middle
+ ConversationInteraction mobj3=new ConversationInteraction();
+ mobj3.setToRole(role);
+ conv.getBlock().getContents().add(mobj3);
+
+ MessageSignature msig3=new MessageSignature();
+ mobj3.setMessageSignature(msig3);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setNamespace("ns");
+ ref3.setLocalpart("lp3");
+
+ msig3.getTypes().add(ref3);
+
+ // Insert into position 1, which should be after first
+ // receive
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+ fail("Failed to insert 3");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ // TODO: Need to check if new service has been inserted
+ // in the middle of the previously inserted interactions
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Now Expecting 2 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
+ }
+
+ if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction:
"+newService.getActions().get(1));
+ }
+
+ ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
+
+ ESBService newService2=model.getService(ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME));
+
+ if (newService2 == null) {
+ fail("Failed to find final service");
+ }
+
+ if (newService2.getActions().size() != 1) {
+ fail("Only expecting one action: "+newService2.getActions().size());
+ }
+
+ ReceiveMessageAction recv4=(ReceiveMessageAction)
+ newService2.getActions().get(0);
+
+ String mtype4=InteractionUtil.getTypeString(ref2);
+
+ if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
+ fail("Message type '"+recv4.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype4);
+ }
+
+
+ ReceiveMessageAction recv3=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+ String mtype3=InteractionUtil.getTypeString(ref3);
+
+ if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
+ fail("Message type '"+recv3.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype3);
+ }
+ }
+
+ public void testInsertMiddleSendBetweenTwoReceives() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setToRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ ((TestESBService)newService).setSessionBased(true);
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
+ }
+
+ ReceiveMessageAction recv2=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+recv2.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ recv2.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // Now second service identified, add new receive
+ // action to ensure that third service inserted in the
+ // middle
+ ConversationInteraction mobj3=new ConversationInteraction();
+ mobj3.setFromRole(role);
+ conv.getBlock().getContents().add(mobj3);
+
+ MessageSignature msig3=new MessageSignature();
+ mobj3.setMessageSignature(msig3);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setNamespace("ns");
+ ref3.setLocalpart("lp3");
+
+ msig3.getTypes().add(ref3);
+
+ // Insert into position 1, which should be after first
+ // receive
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+ fail("Failed to insert 3");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ // TODO: Need to check if new service has been inserted
+ // in the middle of the previously inserted interactions
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Now Expecting 2 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction:
"+newService.getActions().get(0));
+ }
+
+ if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction:
"+newService.getActions().get(1));
+ }
+
+ ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
+
+ ESBService newService2=model.getService(ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME));
+
+ if (newService2 == null) {
+ fail("Failed to find final service");
+ }
+
+ if (newService2.getActions().size() != 1) {
+ fail("Only expecting one action: "+newService2.getActions().size());
+ }
+
+ if ((newService2.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Expecting ReceiveMessageAction, but got:
"+newService2.getActions().get(0));
+ }
+
+ ReceiveMessageAction recv4=(ReceiveMessageAction)
+ newService2.getActions().get(0);
+
+ String mtype4=InteractionUtil.getTypeString(ref2);
+
+ if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
+ fail("Message type '"+recv4.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype4);
+ }
+
+
+ SendMessageAction send3=(SendMessageAction)
+ newService.getActions().get(0);
+
+ String mtype3=InteractionUtil.getTypeString(ref3);
+
+ if (send3.getPropertyValue("messageType").equals(mtype3)==false) {
+ fail("Message type '"+send3.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype3);
+ }
+ }
+
+ public void testInsertMiddleReceiveBetweenTwoSends() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setFromRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setFromRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction send2=(SendMessageAction)
+ service.getActions().get(1);
+
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (send2.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+send2.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ send2.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // Now second service identified, add new receive
+ // action to ensure that third service inserted in the
+ // middle
+ ConversationInteraction mobj3=new ConversationInteraction();
+ mobj3.setToRole(role);
+ conv.getBlock().getContents().add(mobj3);
+
+ MessageSignature msig3=new MessageSignature();
+ mobj3.setMessageSignature(msig3);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setNamespace("ns");
+ ref3.setLocalpart("lp3");
+
+ msig3.getTypes().add(ref3);
+
+ // Insert into position 1, which should be after first
+ // send
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+ fail("Failed to insert 3");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Now Expecting 2 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
+ }
+
+ if ((newService.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction:
"+newService.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ ReceiveMessageAction recv3=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+ String mtype3=InteractionUtil.getTypeString(ref3);
+
+ if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
+ fail("Message type '"+recv3.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype3);
+ }
+ }
+
+ public void testInsertReceiveRequestAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(toRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(toRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR).equals(fromRoleName) ==
false) {
+ fail("Client EPR
'"+action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR)+
+ "' invalid, expecting: "+fromRoleName);
+ }
+ }
+
+ public void testInsertFirstSendAction() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+ }
+
+ public void testInsertSendRequestAction() {
+ String roleName="role1";
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName(roleName);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ if (newService.getCategory().equals(action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+ }
+
+ public void testInsertSendNotReplyAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(fromRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(fromRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION).
+ equals(InteractionUtil.getRoleServiceCategoryProperty(toRoleName)) == false) {
+ fail("Service category expression '"+
+ action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION)+
+ "' invalid, expecting: "+
+ InteractionUtil.getRoleServiceCategoryProperty(toRoleName));
+ }
+
+ if (action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION).
+ equals(InteractionUtil.getRoleServiceNameProperty(toRoleName)) == false) {
+ fail("Service name expression '"+
+ action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION)+
+ "' invalid, expecting: "+
+ InteractionUtil.getRoleServiceNameProperty(toRoleName));
+ }
+ }
+
+ public void testInsertSendReplyAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(fromRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(fromRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setReplyToLabel("replyLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(SendMessageAction.CLIENT_EPR).equals(toRoleName) == false)
{
+ fail("Client EPR
'"+action.getPropertyValue(SendMessageAction.CLIENT_EPR)+
+ "' invalid, expecting: "+toRoleName);
+ }
+ }
+
+ public void testChangeFirstReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp1");
+
+ msig.getTypes().add(ref);
+
+ // Create ReceiveMessageAction
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ java.util.List<Activity> activities=new java.util.Vector<Activity>();
+ action.convert(activities, new DefaultConversionContext(null));
+
+ if (activities.size() != 1) {
+ fail("Expecting single interaction activity from ReceiveMessageAction:
"+activities.size());
+ }
+
+ if ((activities.get(0) instanceof ConversationInteraction) == false) {
+ fail("Not conversation interaction");
+ }
+
+ ConversationInteraction recvci=(ConversationInteraction)activities.get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ // Change local part
+ ref.setLocalpart("lp2");
+
+ if (rule.update(context, model, mobj, recvci) == false) {
+ fail("Failed to update");
+ }
+
+ // Re-check the message type, to make sure has been updated
+ mtype = InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+
+ org.w3c.dom.Element route=mra.getRouteElement(0);
+
+ org.w3c.dom.NodeList
mesgs=route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ if (mesgs.getLength() != 1) {
+ fail("Too many route message elements: "+mesgs.getLength());
+ }
+
+ org.w3c.dom.Element mesg=(org.w3c.dom.Element)mesgs.item(0);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).equals(mtype) == false) {
+ fail("Route message type has not been updated");
+ }
+ }
+
+ public void testDeleteMiddleReceiveBetweenTwoActions() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ TestESBAction act2=new TestESBAction();
+ ((ESBService)context.getParent()).addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ ((TestESBService)newService).setSessionBased(true);
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction:
"+newService.getActions().get(0));
+ }
+
+ if (newService.getActions().get(1) != act2) {
+ fail("Action 2 was not 2nd test ESB action:
"+newService.getActions().get(1));
+ }
+
+ ReceiveMessageAction recv=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ recv.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete receive");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ // TODO: Need to check if new service has been inserted
+ // in the middle of the previously inserted interactions
+
+ // Check actions
+ if (newService.getActions().size() != 1) {
+ fail("Now Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Action 1 was not 2nd test ESB action:
"+newService.getActions().get(0));
+ }
+ }
+
+ public void testDeleteMiddleSendBetweenTwoActions() {
+ ConversationInteractionModelChangeRule rule=new
ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setFromRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ TestESBAction act2=new TestESBAction();
+ ((ESBService)context.getParent()).addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 3) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
+ }
+
+ if (service.getActions().get(2) != act2) {
+ fail("Action 3 was not 2nd test ESB action: "+service.getActions().get(2));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+
+ SendMessageAction send=(SendMessageAction)
+ service.getActions().get(1);
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ send.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete send");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if (service.getActions().get(1) != act2) {
+ fail("Action 2 was not 2nd test ESB action: "+service.getActions().get(1));
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,1069 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.IfModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class IfModelChangeRuleTest extends TestCase {
+
+ public void testInsertIfAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (ifService == null && iter.hasNext()) {
+ ifService = iter.next();
+ if (ifService == service) {
+ ifService = null;
+ }
+ }
+
+ IfAction action=(IfAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 1) {
+ fail("Only one path child expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("if") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(ifService.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+ifService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(ifService.getName()) == false)
{
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+ifService.getName());
+ }
+ }
+
+ public void testInsertIfActionWithSubsequentActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (ifService == null) {
+ ifService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertIfActionWithPrecedingActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof IfAction) == false) {
+ fail("Action 2 was not IfAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (ifService == null) {
+ ifService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertIfElseIfAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService elseIfService1=null;
+ ESBService elseIfService2=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || elseIfService1 == null ||
+ elseIfService2 == null || join==null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ ifService = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ elseIfService1 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ elseIfService2 = serv;
+ }
+ }
+
+ IfAction action=(IfAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("if") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(ifService.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+ifService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(ifService.getName()) == false)
{
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+ifService.getName());
+ }
+
+ if (ifService.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+ifService.getActions().size());
+ }
+
+ if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+ifService.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("elseif") == false) {
+ fail("ElseIf expected but got: "+elem.getNodeName());
+ }
+
+ if
(elem.getAttribute("service-category").equals(elseIfService1.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+elseIfService1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(elseIfService1.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+elseIfService1.getName());
+ }
+
+ if (elseIfService1.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action:
"+elseIfService1.getActions().size());
+ }
+
+ if ((elseIfService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+elseIfService1.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)elseIfService1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("elseif") == false) {
+ fail("ElseIf(2) expected but got: "+elem.getNodeName());
+ }
+
+ if
(elem.getAttribute("service-category").equals(elseIfService2.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+elseIfService2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(elseIfService2.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+elseIfService2.getName());
+ }
+
+ if (elseIfService2.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action:
"+elseIfService2.getActions().size());
+ }
+
+ if ((elseIfService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+elseIfService2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)elseIfService2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertIfElseAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ Block b1=new Block();
+ mobj.setElseBlock(b1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService elseService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || elseService == null ||
+ join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ ifService = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ elseService = serv;
+ }
+ }
+
+ IfAction action=(IfAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("if") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(ifService.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+ifService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(ifService.getName()) == false)
{
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+ifService.getName());
+ }
+
+ if (ifService.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+ifService.getActions().size());
+ }
+
+ if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+ifService.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("else") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(elseService.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+elseService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(elseService.getName()) == false)
{
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+elseService.getName());
+ }
+
+ if (elseService.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+elseService.getActions().size());
+ }
+
+ if ((elseService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+elseService.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)ifService.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ }
+
+ public void testInsertSwitchAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (switchService == null && iter.hasNext()) {
+ switchService = iter.next();
+ if (switchService == service) {
+ switchService = null;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 1) {
+ fail("Only one path child expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Switch expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(switchService.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+switchService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(switchService.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+switchService.getName());
+ }
+ }
+
+ public void testInsertSwitchMultipleCaseAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ Block b1=new Block();
+ mobj.setElseBlock(b1);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ caseService3 = serv;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService1.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService1.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService1.getName());
+ }
+
+ if (caseService1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
+ }
+
+ if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService2.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService2.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService2.getName());
+ }
+
+ if (caseService2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
+ }
+
+ if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService3.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService3.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService3.getName());
+ }
+
+ if (caseService3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
+ }
+
+ if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertSwitchActionWithSubsequentActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((switchService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (switchService == null) {
+ switchService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertSwitchActionWithPrecedingActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("First action not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
+
+ ESBService addedService=model.getService(
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+
+ if (addedService == null) {
+ fail("Failed to find service '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"'
'"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
+ }
+
+ if (addedService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,624 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ParallelModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.analysis.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class ParallelModelChangeRuleTest extends TestCase {
+
+ public void testInsertParallelAction() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Parallel mobj=new Parallel();
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ Block cb2=new Block();
+ mobj.getBlocks().add(cb2);
+
+ Block cb3=new Block();
+ mobj.getBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || s3 == null ||
+ join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 4) {
+ fail("Four path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(1) immediate not set");
+ }
+
+ if (s1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+s1.getActions().size());
+ }
+
+ if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(2) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(2) immediate not set");
+ }
+
+ if (s2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+s2.getActions().size());
+ }
+
+ if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(3) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s3.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s3.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(3) immediate not set");
+ }
+
+ if (s3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+s3.getActions().size());
+ }
+
+ if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(3);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelActionWithImmediateFalse() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ Parallel mobj=new Parallel();
+ conv.getBlock().getContents().add(mobj);
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ cb1.getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("path(1) should not be immediate");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelActionWithImmediateTrue() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setFromRole(role);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ Parallel mobj=new Parallel();
+ conv.getBlock().getContents().add(mobj);
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ cb1.getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(1) should be immediate");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelMiddleAction() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Parallel mobj=new Parallel();
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ Block cb2=new Block();
+ mobj.getBlocks().add(cb2);
+
+ Block cb3=new Block();
+ mobj.getBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(1);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 4) {
+ fail("Four path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(3);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) ==
false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Expecting 1 join action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Action was not test ESB action 2: "+join.getActions().get(0));
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,471 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.RunModelChangeRule;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class RunModelChangeRuleTest extends TestCase {
+
+ public void testInsertPerformAction() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(0);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+ }
+
+ public void testInsertPerformActionMiddle() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Return service should have 1 action:
"+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Expecting test ESB action 2: "+newService.getActions().get(0));
+ }
+
+ }
+ public void testDeletePerformActionMiddle() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ TestESBAction act2=new TestESBAction();
+ ((ESBService)context.getParent()).addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Return service should have 1 action:
"+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Expecting test ESB action 2: "+newService.getActions().get(0));
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ action.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete spawn");
+ }
+
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction ssa=(ScheduleStateAction)service.getActions().get(1);
+
+ if
(ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY).equals(newService.getCategory()) ==
false) {
+ fail("Category not correct
'"+ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY)+
+ "' expecting: "+newService.getCategory());
+ }
+
+ if (ssa.getPropertyValue(PerformAction.SERVICE_NAME).equals(newService.getName()) ==
false) {
+ fail("Name not correct
'"+ssa.getPropertyValue(PerformAction.SERVICE_NAME)+
+ "' expecting: "+newService.getName());
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Return service should have 1 action:
"+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Expecting test ESB action 2: "+newService.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,346 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.RunModelChangeRule;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.SpawnModelChangeRule;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class SpawnModelChangeRuleTest extends TestCase {
+
+ public void testInsertPerformAction() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(0);
+
+ // Check details
+ if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ }
+
+ public void testInsertPerformActionMiddle() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 3) {
+ fail("Expecting 3 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (service.getActions().get(2) != act2) {
+ fail("Expecting test ESB action 2: "+service.getActions().get(2));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ // Check details
+ if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ }
+
+ public void testDeletePerformActionMiddle() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 3) {
+ fail("Expecting 3 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (service.getActions().get(2) != act2) {
+ fail("Expecting test ESB action 2: "+service.getActions().get(2));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ // Check details
+ if
(ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if
(ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ action.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete spawn");
+ }
+
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if (service.getActions().get(1) != act2) {
+ fail("Expecting test ESB action 2: "+service.getActions().get(1));
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,903 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhenModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class WhenModelChangeRuleTest extends TestCase {
+
+ public void testInsertWhenAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhenAction) == false) {
+ fail("Action was not WhenAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ WhenAction action=(WhenAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (s1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+s1.getActions().size());
+ }
+
+ if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(2) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+
+ if (s2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+s2.getActions().size());
+ }
+
+ if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(3) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s3.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s3.getName());
+ }
+
+ if (s3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+s3.getActions().size());
+ }
+
+ if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertWhenActionWithSubsequentActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhenAction) == false) {
+ fail("Action was not WhenAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+
+ public void testInsertWhenActionWithPrecedingActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof WhenAction) == false) {
+ fail("Action 2 was not WhenAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action 2");
+ }
+ }
+
+ public void testInsertSwitchAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (switchService == null && iter.hasNext()) {
+ switchService = iter.next();
+ if (switchService == service) {
+ switchService = null;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 1) {
+ fail("Only one path child expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Switch expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(switchService.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+switchService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(switchService.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+switchService.getName());
+ }
+ }
+
+ public void testInsertSwitchMultipleCaseAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ caseService3 = serv;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Case expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService1.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService1.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService1.getName());
+ }
+
+ if (caseService1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
+ }
+
+ if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Case expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService2.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService2.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService2.getName());
+ }
+
+ if (caseService2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
+ }
+
+ if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService3.getCategory())
== false) {
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService3.getName()) ==
false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService3.getName());
+ }
+
+ if (caseService3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
+ }
+
+ if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"':
"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertSwitchActionWithSubsequentActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ caseService3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertSwitchActionWithPrecedingActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("First action not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
+
+ ESBService addedService=model.getService(
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+
+ if (addedService == null) {
+ fail("Failed to find service '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"'
'"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
+ }
+
+ if (addedService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 6) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java
(from rev 459,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java 2009-01-22
20:41:48 UTC (rev 467)
@@ -0,0 +1,706 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhileModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.analysis.TestLookaheadAnalyser;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class WhileModelChangeRuleTest extends TestCase {
+
+ public void testInsertWhileActionInitiator() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message types: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileActionRecipient() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getBlock().getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 1) {
+ fail("Should have single message type: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileActionRecipientNoRecvLookahead() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setFromRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getBlock().getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message type: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileNotFirstSessionAction() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Make session based service
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction whileSchedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService whileService=null;
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || whileService == null) &&
+ iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ whileService = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ }
+
+ if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(whileService.getCategory()) == false) {
+ fail("While schedule action category '"+
+ whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+
+ "' not expected: "+whileService.getCategory());
+ }
+
+ if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(whileService.getName()) == false) {
+ fail("While schedule action service name '"+
+ whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+
+ "' not expected: "+whileService.getName());
+ }
+
+ if (whileService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+whileService.getActions().size());
+ }
+
+ if ((whileService.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+whileService.getActions().get(0));
+ }
+
+ WhileAction action=(WhileAction)whileService.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message types: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false)
{
+ fail("Service category
'"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileMiddleAction() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Make session based service
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new
java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction whileSchedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService whileService=null;
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || whileService == null) &&
+ iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ whileService = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ }
+
+ if (s2.getActions().size() != 1) {
+ fail("Expecting 1 action in exit service: "+s2.getActions().size());
+ }
+
+ if (s2.getActions().get(0) != act2) {
+ fail("Action in exit is not test ESB action: "+s2.getActions().get(0));
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+