[jboss-svn-commits] JBL Code SVN: r22392 - in labs/jbossesb/trunk/product/services/jbpm/src: test/java/org/jboss/soa/esb/services/jbpm and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Sep 4 09:39:36 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-09-04 09:39:35 -0400 (Thu, 04 Sep 2008)
New Revision: 22392

Added:
   labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/TestJBPMVariable.java
Modified:
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
   labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java
   labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java
   labs/jbossesb/trunk/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml
Log:
Fix jBPM object mapping: JBESB-1966

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java	2008-09-04 13:36:01 UTC (rev 22391)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java	2008-09-04 13:39:35 UTC (rev 22392)
@@ -154,7 +154,7 @@
         String remainingExpression = null;
         int dotPosition=expression.indexOf(".");
         if (dotPosition > 0) {
-            objectName = expression.substring(0, dotPosition-1);
+            objectName = expression.substring(0, dotPosition);
             remainingExpression = expression.substring(dotPosition+1);
         } 
         if (isPrcScope) {

Modified: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java	2008-09-04 13:36:01 UTC (rev 22391)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java	2008-09-04 13:39:35 UTC (rev 22392)
@@ -93,10 +93,14 @@
 
 		String helloWorldTokenScope  = "Hello world token scope";
         String helloWorldGlobalScope = "Hello world process-instance scope";
+        TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
+        TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
 		
 		Token token = processInstance.getRootToken();
         processInstance.getContextInstance().setVariable("v1", helloWorldTokenScope, token);
         processInstance.getContextInstance().setVariable("g2", helloWorldGlobalScope);
+        processInstance.getContextInstance().setVariable("h3", objectTokenScope, token);
+        processInstance.getContextInstance().setVariable("i4", objectGlobalScope);
         ExecutionContext executionContext = new ExecutionContext(token);
         
         JBpmObjectMapper mapper = new JBpmObjectMapper();
@@ -104,6 +108,8 @@
         
         assertEquals(helloWorldTokenScope,String.valueOf(message.getBody().get("esbObj1")));
         assertEquals(helloWorldGlobalScope,String.valueOf(message.getBody().get("esbObj2")));
+        assertEquals(objectTokenScope.getInternal(), String.valueOf(message.getBody().get("esbObj3")));
+        assertEquals(objectGlobalScope.getInternal(), String.valueOf(message.getBody().get("esbObj4")));
 	}
     /**
      * Tests obtaining *no* variables from the jBPM variableMap.
@@ -118,10 +124,14 @@
 
         String helloWorldTokenScope  = "Hello world token scope";
         String helloWorldGlobalScope = "Hello world process-instance scope";
+        TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
+        TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
         
         Token token = processInstance.getRootToken();
         processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
         processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+        processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
+        processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
         ExecutionContext executionContext = new ExecutionContext(token);
         
         JBpmObjectMapper mapper = new JBpmObjectMapper();
@@ -144,18 +154,24 @@
 
         String helloWorldTokenScope  = "Hello world token scope";
         String helloWorldGlobalScope = "Hello world process-instance scope";
+        TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
+        TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
         
         Token token = processInstance.getRootToken();
         processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
         processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+        processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
+        processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
         ExecutionContext executionContext = new ExecutionContext(token);
         
         JBpmObjectMapper mapper = new JBpmObjectMapper();
         Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
         //We should find 2 variables which are named just like their jBPM counterparts.
-        assertEquals(message.getBody().getNames().length,2);
+        assertEquals(message.getBody().getNames().length,4);
         assertEquals(String.valueOf(message.getBody().get("v1")),helloWorldTokenScope);
         assertEquals(String.valueOf(message.getBody().get("g2")),helloWorldGlobalScope);
+        assertEquals(message.getBody().get("h3"), objectTokenScope);
+        assertEquals(message.getBody().get("i4"), objectGlobalScope);
     }
     /**
      * Tests obtaining info about the jBPM ExecutionContext, such as current token and node, transition etc.
@@ -201,9 +217,8 @@
         assertEquals(String.valueOf(String.valueOf(message.getBody().get("piVersion"))), String.valueOf(processInstance.getVersion()));
         logger.info("Message=" + message);
     }
-    
+
     public static junit.framework.Test suite(){
         return new JUnit4TestAdapter(JBpmObjectMapperUnitTest.class);
     }
-
 }

Added: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/TestJBPMVariable.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/TestJBPMVariable.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/TestJBPMVariable.java	2008-09-04 13:39:35 UTC (rev 22392)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.services.jbpm;
+
+/**
+ * Test class used to test object manipulation for JBpmObjectMapper
+ * 
+ * @author kevin
+ *
+ */
+public final class TestJBPMVariable
+{
+    private String internal ;
+    
+    public TestJBPMVariable(final String internal)
+    {
+        this.internal = internal ;
+    }
+    
+    public String getInternal()
+    {
+        return internal ;
+    }
+    
+    public void setInternal(final String internal)
+    {
+        this.internal = internal ;
+    }
+    
+    @Override
+    public int hashCode()
+    {
+        return internal.hashCode() ;
+    }
+    
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (obj instanceof TestJBPMVariable)
+        {
+            return internal.equals(((TestJBPMVariable)obj).getInternal()) ;
+        }
+        return false ;
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/TestJBPMVariable.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java	2008-09-04 13:36:01 UTC (rev 22391)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java	2008-09-04 13:39:35 UTC (rev 22392)
@@ -39,6 +39,7 @@
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.services.jbpm.Constants;
 import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
+import org.jboss.soa.esb.services.jbpm.TestJBPMVariable;
 import org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ExecutionContext;
@@ -89,10 +90,14 @@
         
         String helloWorldTokenScope  = "Hello world token scope";
         String helloWorldGlobalScope = "Hello world process-instance scope";
+        TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
+        TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
         
         Token token = processInstance.getRootToken();
         processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
         processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+        processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
+        processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
         ExecutionContext executionContext = new ExecutionContext(token);
         
         JBpmObjectMapper mapper = new JBpmObjectMapper();
@@ -111,6 +116,7 @@
         assertEquals(helloWorldGlobalScope,variableMap.get("x2"));
     }
     
+
     public static junit.framework.Test suite(){
         return new JUnit4TestAdapter(JBpmObjectMapperCallbackUnitTest.class);
     }

Modified: labs/jbossesb/trunk/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml	2008-09-04 13:36:01 UTC (rev 22391)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml	2008-09-04 13:39:35 UTC (rev 22392)
@@ -11,6 +11,8 @@
       		<bpmToEsbVars>
       			<mapping bpm="v1" esb="esbObj1" />
       			<mapping bpm="g2" esb="esbObj2" process-scope="true" />
+      			<mapping bpm="h3.internal" esb="esbObj3" />
+      			<mapping bpm="i4.internal" esb="esbObj4" process-scope="true" />
       		</bpmToEsbVars>
       		<esbToBpmVars>
       			<mapping esb="esbObj1" bpm="x1" process-scope="true" />




More information about the jboss-svn-commits mailing list