[overlord-commits] Overlord SVN: r347 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Fri Sep 26 10:56:27 EDT 2008


Author: objectiser
Date: 2008-09-26 10:56:27 -0400 (Fri, 26 Sep 2008)
New Revision: 347

Modified:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
Log:
Additional test to insert a receive between two sends.

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java	2008-09-26 14:15:53 UTC (rev 346)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java	2008-09-26 14:56:27 UTC (rev 347)
@@ -260,7 +260,7 @@
 	}		
 	
 
-	public void testInsertThirdMiddleReceiveAction() {
+	public void testInsertMiddleReceiveBetweenTwoReceives() {
 		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
 		
 		TestESBLanguageModel model=new TestESBLanguageModel();
@@ -509,7 +509,7 @@
 		}
 	}		
 	
-	public void testInsertThirdMiddleSendAction() {
+	public void testInsertMiddleSendBetweenTwoReceives() {
 		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
 		
 		TestESBLanguageModel model=new TestESBLanguageModel();
@@ -762,6 +762,211 @@
 		}
 	}		
 
+	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";




More information about the overlord-commits mailing list