[jboss-svn-commits] JBL Code SVN: r31001 - in labs/jbossrules/branches/true_modify_20100104/drools-core/src: main/java/org/drools/util/debug and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Jan 10 21:34:15 EST 2010


Author: tirelli
Date: 2010-01-10 21:34:14 -0500 (Sun, 10 Jan 2010)
New Revision: 31001

Added:
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/InstrumentedRuleTerminalNode.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/BindingStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/CollectNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/DslStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ExistsNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/FactsStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ForallNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/JoinNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftInputAdapterNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftTupleSinkStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NotNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ObjectTypeNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ReteTesterHelper.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/RuleTerminalNodeStep.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/Step.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/WithStep.java
Modified:
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/FromNodeVisitor.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/RuleTerminalNodeVisitor.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/Person.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/CollectNodeTest.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngine.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineHelper.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineTest.java
   labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/CollectNodeAssertRetractTest.data
Log:
JBRULES-2240: implementing proper collect node support. JBRULES-2339: adding support to collect node and to mock nodes to the test harness

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/CollectNode.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/CollectNode.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -16,6 +16,15 @@
 
 package org.drools.reteoo;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
 import org.drools.RuleBaseConfiguration;
 import org.drools.common.BetaConstraints;
 import org.drools.common.InternalFactHandle;
@@ -26,6 +35,7 @@
 import org.drools.rule.Collect;
 import org.drools.rule.ContextEntry;
 import org.drools.rule.Declaration;
+import org.drools.rule.Pattern;
 import org.drools.spi.AlphaNodeFieldConstraint;
 import org.drools.spi.BetaNodeFieldConstraint;
 import org.drools.spi.PropagationContext;
@@ -34,15 +44,6 @@
 import org.drools.util.Iterator;
 import org.drools.util.ObjectHashMap.ObjectEntry;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
 /**
  * @author etirelli
  *
@@ -54,7 +55,8 @@
     private AlphaNodeFieldConstraint[] resultConstraints;
     private BetaConstraints            resultsBinder;
     private boolean                    unwrapRightObject;
-    private Declaration[]              requiredDeclarations;
+    private Pattern[]                  requiredPatterns;
+
     public CollectNode() {
     }
 
@@ -97,7 +99,7 @@
         this.collect = collect;
         this.unwrapRightObject = unwrapRight;
         this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
-        
+
         List<Declaration> declrs = new ArrayList<Declaration>();
         int maxIndex = 0;
         for ( BetaNodeFieldConstraint constraint : getConstraints() ) {
@@ -105,12 +107,12 @@
                 if ( declr.getPattern().getOffset() > maxIndex ) {
                     maxIndex = declr.getPattern().getOffset();
                 }
-                declrs.add(  declr );
+                declrs.add( declr );
             }
         }
-        requiredDeclarations = new Declaration[ maxIndex ];
+        requiredPatterns = new Pattern[maxIndex + 1];
         for ( Declaration declr : declrs ) {
-            requiredDeclarations[declr.getPattern().getOffset()] = declr;
+            requiredPatterns[declr.getPattern().getOffset()] = declr.getPattern();
         }
     }
 
@@ -144,20 +146,31 @@
      *  4.2. Propagate the tuple
      *
      */
+    @SuppressWarnings("unchecked")
     public void assertLeftTuple(final LeftTuple leftTuple,
                                 final PropagationContext context,
                                 final InternalWorkingMemory workingMemory) {
 
         final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
-        
-        CollectContext colctx = ( CollectContext ) memory.betaMemory.getCreatedHandles().get( leftTuple );
 
-        final Collection result = this.collect.instantiateResultObject( workingMemory );
+        final Collection<Object> result = (Collection<Object>) this.collect.instantiateResultObject( workingMemory );
         final InternalFactHandle resultHandle = workingMemory.getFactHandleFactory().newFactHandle( result,
                                                                                                     workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( context.getEntryPoint(),
                                                                                                                                                                           result ),
                                                                                                     workingMemory );
 
+        final CollectContext colctx = new CollectContext();
+        colctx.resultTuple = new RightTuple( resultHandle,
+                                             this );
+
+        // do not add tuple and result to the memory in sequential mode
+        if ( this.tupleMemoryEnabled ) {
+            memory.betaMemory.getLeftTupleMemory().add( leftTuple );
+            memory.betaMemory.getCreatedHandles().put( leftTuple,
+                                                       colctx,
+                                                       false );
+        }
+
         this.constraints.updateFromTuple( memory.betaMemory.getContext(),
                                           workingMemory,
                                           leftTuple );
@@ -184,7 +197,8 @@
 
         this.constraints.resetTuple( memory.betaMemory.getContext() );
 
-        evaluateResultConstraints( leftTuple,
+        evaluateResultConstraints( ActivitySource.LEFT,
+                                   leftTuple,
                                    context,
                                    workingMemory,
                                    memory,
@@ -264,9 +278,11 @@
             LeftTuple tuple = (LeftTuple) tuples[i];
             if ( this.constraints.isAllowedCachedRight( memory.betaMemory.getContext(),
                                                         tuple ) ) {
-                modifyTuple( true,
+                modifyTuple( ActivitySource.RIGHT,
+                             true,
                              tuple,
                              rightTuple,
+                             null,
                              context,
                              workingMemory,
                              memory );
@@ -275,72 +291,7 @@
 
         this.constraints.resetFactHandle( memory.betaMemory.getContext() );
     }
-    
 
-    public void modifyLeftTuple(LeftTuple leftTuple,
-                                PropagationContext context,
-                                InternalWorkingMemory workingMemory) {
-
-        final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
-
-        final Collection result = this.collect.instantiateResultObject( workingMemory );
-        final InternalFactHandle resultHandle = workingMemory.getFactHandleFactory().newFactHandle( result,
-                                                                                                    workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( context.getEntryPoint(),
-                                                                                                                                                                          result ),
-                                                                                                    workingMemory );
-
-        final CollectContext colctx = new CollectContext();
-        colctx.resultTuple = new RightTuple( resultHandle,
-                                             this );
-
-        // do not add tuple and result to the memory in sequential mode
-        if ( this.tupleMemoryEnabled ) {
-            memory.betaMemory.getLeftTupleMemory().add( leftTuple );
-            memory.betaMemory.getCreatedHandles().put( leftTuple,
-                                                       colctx,
-                                                       false );
-        }
-
-        this.constraints.updateFromTuple( memory.betaMemory.getContext(),
-                                          workingMemory,
-                                          leftTuple );
-
-        for ( RightTuple rightTuple = memory.betaMemory.getRightTupleMemory().getFirst( leftTuple ); rightTuple != null; rightTuple = (RightTuple) rightTuple.getNext() ) {
-            InternalFactHandle handle = rightTuple.getFactHandle();
-            if ( this.constraints.isAllowedCachedLeft( memory.betaMemory.getContext(),
-                                                       handle ) ) {
-                if ( this.unwrapRightObject ) {
-                    handle = ((LeftTuple) handle.getObject()).getLastHandle();
-                }
-                result.add( handle.getObject() );
-
-                // in sequential mode, we don't need to keep record of matched tuples
-                if ( this.tupleMemoryEnabled ) {
-                    // linking left and right by creating a new left tuple
-                    new LeftTuple( leftTuple,
-                                   rightTuple,
-                                   this,
-                                   this.tupleMemoryEnabled );
-                }
-            }
-        }
-
-        this.constraints.resetTuple( memory.betaMemory.getContext() );
-
-        evaluateResultConstraints( leftTuple,
-                                   context,
-                                   workingMemory,
-                                   memory,
-                                   colctx );        
-    }
-
-    public void modifyRightTuple(RightTuple rightTuple,
-                                 PropagationContext context,
-                                 InternalWorkingMemory workingMemory) {
-        // TODO Auto-generated method stub
-        
-    }    
-
     /**
      *  @inheritDoc
      *
@@ -352,32 +303,49 @@
                                   final InternalWorkingMemory workingMemory) {
 
         final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
-        
+
         final InternalFactHandle origin = (InternalFactHandle) context.getFactHandleOrigin();
-        if( context.getType() == PropagationContext.EXPIRATION ) {
-            ((PropagationContextImpl)context).setFactHandle( null );
+        if ( context.getType() == PropagationContext.EXPIRATION ) {
+            ((PropagationContextImpl) context).setFactHandle( null );
         }
-        
-        behavior.retractRightTuple( memory.betaMemory.getBehaviorContext(), rightTuple, workingMemory );
+
+        behavior.retractRightTuple( memory.betaMemory.getBehaviorContext(),
+                                    rightTuple,
+                                    workingMemory );
         memory.betaMemory.getRightTupleMemory().remove( rightTuple );
 
-        for ( LeftTuple leftTuple = rightTuple.firstChild; leftTuple != null; ) {
-            LeftTuple tmp = leftTuple.getRightParentNext();
-            this.modifyTuple( false,
-                              leftTuple.getParent(),
+        for ( LeftTuple child = rightTuple.firstChild; child != null; ) {
+            LeftTuple tmp = child.getRightParentNext();
+            this.modifyTuple( ActivitySource.RIGHT,
+                              false,
+                              child.getParent(),
                               rightTuple,
+                              child,
                               context,
                               workingMemory,
                               memory );
-            leftTuple = tmp;
+            child = tmp;
         }
 
-        if( context.getType() == PropagationContext.EXPIRATION ) {
-            ((PropagationContextImpl)context).setFactHandle( origin );
+        if ( context.getType() == PropagationContext.EXPIRATION ) {
+            ((PropagationContextImpl) context).setFactHandle( origin );
         }
 
     }
 
+    public void modifyLeftTuple(LeftTuple leftTuple,
+                                PropagationContext context,
+                                InternalWorkingMemory workingMemory) {
+
+    }
+
+    public void modifyRightTuple(RightTuple rightTuple,
+                                 PropagationContext context,
+                                 InternalWorkingMemory workingMemory) {
+        // TODO Auto-generated method stub
+
+    }
+
     /**
      * Modifies the results match for a tuple, retracting it and repropagating
      * if constraints allow it
@@ -387,52 +355,33 @@
      * @param context
      * @param workingMemory
      */
-    public void modifyTuple(final boolean isAssert,
+    @SuppressWarnings("unchecked")
+    public void modifyTuple(final ActivitySource activitySource,
+                            final boolean isAssert,
                             final LeftTuple leftTuple,
                             final RightTuple rightTuple,
+                            final LeftTuple match,
                             final PropagationContext context,
                             final InternalWorkingMemory workingMemory,
                             final CollectMemory memory) {
 
         final CollectContext colctx = (CollectContext) memory.betaMemory.getCreatedHandles().get( leftTuple );
 
-        // if tuple was propagated
-        if ( colctx.propagated ) {
-            LeftTuple firstMatch = getFirstMatch( leftTuple, colctx );
-            
-            // we may have no matches yet
-            if( firstMatch != null ) { 
-                // temporarily break the linked list to avoid wrong retracts
-                firstMatch.getLeftParentPrevious().setLeftParentNext( null );
-                firstMatch.setLeftParentPrevious( null );
-            }
-            this.sink.propagateRetractLeftTuple( leftTuple,
-                                                 context,
-                                                 workingMemory );
-            // now set the beta children to the first match
-            leftTuple.firstChild = firstMatch;
-            colctx.propagated = false;
-        }
-
-        if( isAssert ) {
+        if ( isAssert ) {
             // linking left and right by creating a new left tuple
             new LeftTuple( leftTuple,
                            rightTuple,
                            this,
                            this.tupleMemoryEnabled );
         } else {
-            if( leftTuple.firstChild != null ) {
+            if ( match != null ) {
                 // removing link between left and right
-                LeftTuple match = leftTuple.firstChild;
-                while( match.getRightParent() != rightTuple ) {
-                    match = match.getLeftParentNext();
-                }
                 match.unlinkFromLeftParent();
                 match.unlinkFromRightParent();
             }
         }
-        
-        // if there is a subnetwork, we need to unwrapp the object from inside the tuple
+
+        // if there is a subnetwork, we need to unwrap the object from inside the tuple
         InternalFactHandle handle = rightTuple.getFactHandle();
         if ( this.unwrapRightObject ) {
             handle = ((LeftTuple) handle.getObject()).getLastHandle();
@@ -443,14 +392,16 @@
         } else if ( context.getType() == PropagationContext.RETRACTION || context.getType() == PropagationContext.EXPIRATION ) {
             ((Collection) colctx.resultTuple.getFactHandle().getObject()).remove( handle.getObject() );
         } else if ( context.getType() == PropagationContext.MODIFICATION || context.getType() == PropagationContext.RULE_ADDITION || context.getType() == PropagationContext.RULE_REMOVAL ) {
+            // TODO: need to review this
             if ( isAssert ) {
                 ((Collection) colctx.resultTuple.getFactHandle().getObject()).add( handle.getObject() );
             } else {
                 ((Collection) colctx.resultTuple.getFactHandle().getObject()).remove( handle.getObject() );
             }
         }
-        
-        evaluateResultConstraints( leftTuple,
+
+        evaluateResultConstraints( activitySource,
+                                   leftTuple,
                                    context,
                                    workingMemory,
                                    memory,
@@ -466,7 +417,8 @@
      * @param memory
      * @param colctx
      */
-    private void evaluateResultConstraints(final LeftTuple leftTuple,
+    private void evaluateResultConstraints(final ActivitySource source,
+                                           final LeftTuple leftTuple,
                                            final PropagationContext context,
                                            final InternalWorkingMemory workingMemory,
                                            final CollectMemory memory,
@@ -485,18 +437,56 @@
             this.resultsBinder.updateFromTuple( memory.resultsContext,
                                                 workingMemory,
                                                 leftTuple );
-            if ( this.resultsBinder.isAllowedCachedLeft( memory.resultsContext,
-                                                         colctx.resultTuple.getFactHandle() ) ) {
-                colctx.propagated = true;
+            if ( !this.resultsBinder.isAllowedCachedLeft( memory.resultsContext,
+                                                          colctx.resultTuple.getFactHandle() ) ) {
+                isAllowed = false;
+            }
+
+            this.resultsBinder.resetTuple( memory.resultsContext );
+        }
+
+        // temporarily break the linked list to avoid wrong interactions
+        LeftTuple[] matchings = splitList( leftTuple,
+                                           colctx );
+
+        if ( colctx.propagated == true ) {
+            if ( isAllowed ) {
+                // modify 
+                if ( ActivitySource.LEFT.equals( source ) ) {
+                    this.sink.propagateModifyChildLeftTuple( leftTuple.firstChild,
+                                                             leftTuple,
+                                                             context,
+                                                             workingMemory,
+                                                             this.tupleMemoryEnabled );
+                } else {
+                    this.sink.propagateModifyChildLeftTuple( leftTuple.firstChild,
+                                                             colctx.resultTuple,
+                                                             context,
+                                                             workingMemory,
+                                                             this.tupleMemoryEnabled );
+                }
+            } else {
+                // retract
+                this.sink.propagateRetractLeftTuple( leftTuple,
+                                                     context,
+                                                     workingMemory );
+                colctx.propagated = false;
+            }
+        } else {
+            if ( isAllowed ) {
+                // assert
                 this.sink.propagateAssertLeftTuple( leftTuple,
                                                     colctx.resultTuple,
                                                     context,
                                                     workingMemory,
                                                     this.tupleMemoryEnabled );
+                colctx.propagated = true;
             }
+        }
 
-            this.resultsBinder.resetTuple( memory.resultsContext );
-        }
+        // restore the matchings list
+        restoreList( leftTuple,
+                     matchings );
     }
 
     /**
@@ -530,7 +520,7 @@
         final Iterator tupleIter = memory.betaMemory.getLeftTupleMemory().iterator();
         for ( LeftTuple leftTuple = (LeftTuple) tupleIter.next(); leftTuple != null; leftTuple = (LeftTuple) tupleIter.next() ) {
             CollectContext colctx = (CollectContext) memory.betaMemory.getCreatedHandles().get( leftTuple );
-            if( colctx.propagated ) {
+            if ( colctx.propagated ) {
                 sink.assertLeftTuple( new LeftTuple( leftTuple,
                                                      colctx.resultTuple,
                                                      sink,
@@ -540,15 +530,15 @@
             }
         }
     }
-    
+
     protected void doRemove(final InternalWorkingMemory workingMemory,
                             final CollectMemory memory) {
-          Iterator it = memory.betaMemory.getCreatedHandles().iterator();
-          for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
-              CollectContext ctx = ( CollectContext ) entry.getValue();
-              workingMemory.getFactHandleFactory().destroyFactHandle( ctx.resultTuple.getFactHandle() );              
-          }    
-    }    
+        Iterator it = memory.betaMemory.getCreatedHandles().iterator();
+        for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
+            CollectContext ctx = (CollectContext) entry.getValue();
+            workingMemory.getFactHandleFactory().destroyFactHandle( ctx.resultTuple.getFactHandle() );
+        }
+    }
 
     /* (non-Javadoc)
      * @see org.drools.reteoo.BaseNode#hashCode()
@@ -593,11 +583,44 @@
         memory.betaMemory.setBehaviorContext( this.behavior.createBehaviorContext() );
         return memory;
     }
-    
+
     public short getType() {
         return NodeTypeEnums.CollectNode;
-    }   
+    }
 
+    private LeftTuple[] splitList(final LeftTuple parent,
+                                  final CollectContext colctx) {
+        LeftTuple[] matchings = new LeftTuple[2];
+
+        // save the matchings list
+        matchings[0] = getFirstMatch( parent,
+                                      colctx );
+        matchings[1] = parent.lastChild;
+
+        // update the tuple for the actual propagations
+        if ( matchings[0] != null ) {
+            if ( parent.firstChild == matchings[0] ) {
+                parent.firstChild = null;
+            }
+            parent.lastChild = matchings[0].getLeftParentPrevious();
+        }
+
+        return matchings;
+    }
+
+    private void restoreList(final LeftTuple parent,
+                             final LeftTuple[] matchings) {
+        // concatenate matchings list at the end of the children list
+        if ( parent.firstChild == null ) {
+            parent.firstChild = matchings[0];
+            parent.lastChild = matchings[1];
+        } else if ( matchings[0] != null ) {
+            parent.lastChild.setLeftParentNext( matchings[0] );
+            matchings[0].setLeftParentPrevious( parent.lastChild );
+            parent.lastChild = matchings[1];
+        }
+    }
+
     public static class CollectMemory
         implements
         Externalizable {
@@ -626,12 +649,13 @@
         private static final long serialVersionUID = -3076306175989410574L;
         public RightTuple         resultTuple;
         public boolean            propagated;
-        
+
         public void readExternal(ObjectInput in) throws IOException,
-                                                  ClassNotFoundException {
+                                                ClassNotFoundException {
             resultTuple = (RightTuple) in.readObject();
             propagated = in.readBoolean();
         }
+
         public void writeExternal(ObjectOutput out) throws IOException {
             out.writeObject( resultTuple );
             out.writeBoolean( propagated );
@@ -639,5 +663,8 @@
 
     }
 
+    private static enum ActivitySource {
+        LEFT, RIGHT
+    }
 
 }

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -88,7 +88,7 @@
      *            The <code>TupleSink</code> to receive propagated
      *            <code>Tuples</code>.
      */
-    protected void addTupleSink(final LeftTupleSink tupleSink) {
+    public void addTupleSink(final LeftTupleSink tupleSink) {
         if ( this.sink instanceof EmptyLeftTupleSinkAdapter ) {
             if( this.partitionsEnabled && ! this.partitionId.equals( tupleSink.getPartitionId() ) ) {
                 // if partitions are enabled and the next node belongs to a different partition,

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/FromNodeVisitor.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/FromNodeVisitor.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/FromNodeVisitor.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -30,7 +30,7 @@
             long handles = 0;
             org.drools.util.Iterator it = memory.betaMemory.getLeftTupleMemory().iterator();
             for ( LeftTuple leftTuple = (LeftTuple) it.next(); leftTuple != null; leftTuple = (LeftTuple) it.next() ) {
-                LeftTuple child = leftTuple.getBetaChildren();
+                LeftTuple child = leftTuple.firstChild;
                 while( child != null ) {
                     handles++;
                     child = child.getLeftParentNext();

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/RuleTerminalNodeVisitor.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/RuleTerminalNodeVisitor.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/util/debug/RuleTerminalNodeVisitor.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -4,7 +4,6 @@
 
 import org.drools.common.NetworkNode;
 import org.drools.reteoo.RuleTerminalNode;
-import org.drools.reteoo.RuleTerminalNode.TerminalNodeMemory;
 import org.drools.rule.Rule;
 
 public class RuleTerminalNodeVisitor extends AbstractNetworkNodeVisitor {
@@ -25,11 +24,8 @@
             info.assign( snode, rule );
         }
 
-        final TerminalNodeMemory memory = (TerminalNodeMemory) info.getSession().getNodeMemory( rtn );
         final DefaultNodeInfo ni = (DefaultNodeInfo) info.getNodeInfo( node );
-        ni.setMemoryEnabled( true );
-        ni.setTupleMemorySize( memory.getTupleMemory().size() );
-
+        ni.setMemoryEnabled( false );
     }
 
 }

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/Person.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/Person.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/Person.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -11,6 +11,8 @@
     private String name;
     private int    age;
     
+    private String likes;
+    
     private String street;
     private String city;
     private String state;
@@ -27,8 +29,15 @@
     
     public Person(final String name,
                   final int age) {
+        this( name, age, null );
+    }
+
+    public Person(final String name,
+                  final int age, 
+                  final String likes ) {
         this.name = name;
         this.age = age;
+        this.likes = likes;
         this.addresses = new HashMap();
         this.addressList = new ArrayList();
         this.addressArray = new Address[10];
@@ -171,6 +180,14 @@
             if ( other.street != null ) return false;
         } else if ( !street.equals( other.street ) ) return false;
         return true;
+    }
+
+    public String getLikes() {
+        return likes;
+    }
+
+    public void setLikes(String likes) {
+        this.likes = likes;
     }        
     
 }

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/CollectNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/CollectNodeTest.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/CollectNodeTest.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -1,5 +1,6 @@
 package org.drools.reteoo.test;
 
+
 import junit.framework.TestCase;
 
 public class CollectNodeTest extends TestCase {

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -1,5 +1,6 @@
 package org.drools.reteoo.test;
 
+
 import junit.framework.TestCase;
 
 public class ExistsNodeTest extends TestCase {

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/InstrumentedRuleTerminalNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/InstrumentedRuleTerminalNode.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/InstrumentedRuleTerminalNode.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.drools.RuleBaseConfiguration;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.LeftTuple;
+import org.drools.reteoo.LeftTupleSource;
+import org.drools.reteoo.RuleTerminalNode;
+import org.drools.reteoo.builder.BuildContext;
+import org.drools.rule.GroupElement;
+import org.drools.rule.Rule;
+import org.drools.spi.PropagationContext;
+
+public class InstrumentedRuleTerminalNode extends RuleTerminalNode {
+
+    public InstrumentedRuleTerminalNode(final int id,
+                                        final LeftTupleSource source,
+                                        final Rule rule,
+                                        final GroupElement subrule,
+                                        final BuildContext context) {
+        super( id,
+               source,
+               rule,
+               subrule,
+               context );
+    }
+
+    @Override
+    public void assertLeftTuple(LeftTuple leftTuple,
+                                PropagationContext context,
+                                InternalWorkingMemory workingMemory) {
+        Set<LeftTuple> set = (Set<LeftTuple>) workingMemory.getNodeMemory( this );
+        set.add( leftTuple );
+        super.assertLeftTuple( leftTuple,
+                               context,
+                               workingMemory );
+    }
+
+    @Override
+    public void retractLeftTuple(LeftTuple leftTuple,
+                                 PropagationContext context,
+                                 InternalWorkingMemory workingMemory) {
+        Set<LeftTuple> set = (Set<LeftTuple>) workingMemory.getNodeMemory( this );
+        set.remove( leftTuple );
+        super.retractLeftTuple( leftTuple,
+                                context,
+                                workingMemory );
+    }
+
+    @Override
+    public Object createMemory(RuleBaseConfiguration config) {
+        return new LinkedHashSet<LeftTuple>();
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/InstrumentedRuleTerminalNode.java
___________________________________________________________________
Name: svn:executable
   + *

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -1,5 +1,6 @@
 package org.drools.reteoo.test;
 
+
 import junit.framework.TestCase;
 
 public class JoinNodeTest extends TestCase {

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -1,5 +1,6 @@
 package org.drools.reteoo.test;
 
+
 import junit.framework.TestCase;
 
 public class NotNodeTest extends TestCase {

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngine.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngine.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngine.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -1,74 +1,58 @@
 package org.drools.reteoo.test;
 
-import java.beans.IntrospectionException;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.drools.FactHandle;
 import org.drools.RuleBaseConfiguration;
-import org.drools.WorkingMemory;
-import org.drools.base.ClassFieldAccessorCache;
-import org.drools.base.ClassFieldAccessorStore;
-import org.drools.base.ClassObjectType;
-import org.drools.base.ClassTypeResolver;
-import org.drools.base.ValueType;
-import org.drools.base.evaluators.EvaluatorRegistry;
-import org.drools.base.evaluators.Operator;
-import org.drools.common.EmptyBetaConstraints;
 import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalWorkingMemory;
 import org.drools.common.PropagationContextImpl;
-import org.drools.common.SingleBetaConstraints;
 import org.drools.reteoo.BetaMemory;
 import org.drools.reteoo.BetaNode;
 import org.drools.reteoo.CollectNode;
-import org.drools.reteoo.EntryPointNode;
-import org.drools.reteoo.ExistsNode;
-import org.drools.reteoo.JoinNode;
-import org.drools.reteoo.LeftInputAdapterNode;
 import org.drools.reteoo.LeftTuple;
 import org.drools.reteoo.LeftTupleMemory;
-import org.drools.reteoo.LeftTupleSource;
-import org.drools.reteoo.MockObjectSource;
-import org.drools.reteoo.MockTupleSource;
+import org.drools.reteoo.LeftTupleSink;
 import org.drools.reteoo.ModifyPreviousTuples;
-import org.drools.reteoo.NotNode;
-import org.drools.reteoo.ObjectSource;
 import org.drools.reteoo.ObjectTypeNode;
 import org.drools.reteoo.ReteooRuleBase;
 import org.drools.reteoo.RightTuple;
 import org.drools.reteoo.RightTupleMemory;
 import org.drools.reteoo.RuleTerminalNode;
+import org.drools.reteoo.CollectNode.CollectMemory;
 import org.drools.reteoo.builder.BuildContext;
-import org.drools.rule.BehaviorManager;
-import org.drools.rule.Collect;
-import org.drools.rule.Declaration;
-import org.drools.rule.GroupElement;
-import org.drools.rule.Package;
-import org.drools.rule.Pattern;
-import org.drools.rule.Rule;
-import org.drools.rule.VariableConstraint;
-import org.drools.spi.AlphaNodeFieldConstraint;
-import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.Consequence;
-import org.drools.spi.Evaluator;
-import org.drools.spi.InternalReadAccessor;
-import org.drools.spi.KnowledgeHelper;
+import org.drools.reteoo.test.dsl.BindingStep;
+import org.drools.reteoo.test.dsl.CollectNodeStep;
+import org.drools.reteoo.test.dsl.DslStep;
+import org.drools.reteoo.test.dsl.ExistsNodeStep;
+import org.drools.reteoo.test.dsl.FactsStep;
+import org.drools.reteoo.test.dsl.ForallNodeStep;
+import org.drools.reteoo.test.dsl.JoinNodeStep;
+import org.drools.reteoo.test.dsl.LeftInputAdapterNodeStep;
+import org.drools.reteoo.test.dsl.LeftTupleSinkStep;
+import org.drools.reteoo.test.dsl.NotNodeStep;
+import org.drools.reteoo.test.dsl.ObjectTypeNodeStep;
+import org.drools.reteoo.test.dsl.ReteTesterHelper;
+import org.drools.reteoo.test.dsl.RuleTerminalNodeStep;
+import org.drools.reteoo.test.dsl.Step;
+import org.drools.reteoo.test.dsl.WithStep;
 import org.drools.spi.PropagationContext;
 import org.drools.util.StringUtils;
+import org.mockito.exceptions.base.MockitoAssertionError;
 import org.mvel2.MVEL;
 
+import static org.mockito.Mockito.*;
+
 public class ReteDslTestEngine {
 
+    private static final String LEFT_TUPLE_SINK_STEP = "LeftTupleSink";
     private ReteTesterHelper    reteTesterHelper;
     private Map<String, Object> steps;
 
@@ -94,6 +78,8 @@
                         new CollectNodeStep( this.reteTesterHelper ) );
         this.steps.put( "RuleTerminalNode",
                         new RuleTerminalNodeStep( this.reteTesterHelper ) );
+        this.steps.put( LEFT_TUPLE_SINK_STEP,
+                        new LeftTupleSinkStep( this.reteTesterHelper ) );
         this.steps.put( "Facts",
                         new FactsStep( this.reteTesterHelper ) );
         this.steps.put( "With",
@@ -161,6 +147,13 @@
                                       (RuleTerminalNode) node,
                                       context,
                                       wm );
+                } else if ( node instanceof LeftTupleSink ) {
+                    LeftTupleSinkStep impl = (LeftTupleSinkStep) this.steps.get( LEFT_TUPLE_SINK_STEP );
+                    // it might be a mock
+                    impl.process( step,
+                                  (LeftTupleSink) node,
+                                  context,
+                                  wm );
                 } else {
                     throw new IllegalArgumentException( "line " + step.getLine() + ": unknown node " + node );
                 }
@@ -178,7 +171,13 @@
             String[] cmds = step.getCommands().toArray( new String[0] );
             List<InternalFactHandle> handles = (List<InternalFactHandle>) context.get( "Handles" );
 
-            BetaMemory memory = (BetaMemory) wm.getNodeMemory( node );
+            BetaMemory memory = null;
+            if ( node instanceof CollectNode ) {
+                CollectMemory colmem = (CollectMemory) wm.getNodeMemory( node );
+                memory = colmem.betaMemory;
+            } else {
+                memory = (BetaMemory) wm.getNodeMemory( node );
+            }
             for ( String cmd : cmds ) {
                 if ( cmd.trim().startsWith( "leftMemory" ) ) {
                     int pos = cmd.indexOf( "[" );
@@ -646,807 +645,4 @@
 
         return lines;
     }
-
-    public static class DslStep {
-        private int          line;
-
-        private String       name;
-        private List<String> commands;
-
-        public DslStep(int line,
-                       String name,
-                       List<String> commands) {
-            this.line = line;
-            this.name = name;
-            this.commands = commands;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public int getLine() {
-            return line;
-        }
-
-        public List<String> getCommands() {
-            return commands;
-        }
-
-        public String toString() {
-            return line + " : " + name + " : " + commands;
-        }
-
-    }
-
-    public static interface Step {
-        public void execute(Map<String, Object> context,
-                            String[] args);
-    }
-
-    public static class ObjectTypeNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public ObjectTypeNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-            String name;
-            String type;
-
-            if ( args.length == 1 ) {
-                String[] c = args[0].split( "," );
-                name = c[0].trim();
-                type = c[1].trim();
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
-            }
-            ObjectTypeNode otn;
-            try {
-                EntryPointNode epn = new EntryPointNode( buildContext.getNextId(),
-                                                         buildContext.getRuleBase().getRete(),
-                                                         buildContext );
-                epn.attach();
-
-                otn = new ObjectTypeNode( buildContext.getNextId(),
-                                          epn,
-                                          new ClassObjectType( Class.forName( type ) ),
-                                          buildContext );
-                // we don't attach, as we want to manually propagate and not
-                // have the working memory propagate
-                //otn.attach();
-            } catch ( ClassNotFoundException e ) {
-                throw new IllegalArgumentException( "Cannot create OTN " + Arrays.asList( args,
-                                                                                          e ) );
-            }
-            context.put( name,
-                         otn );
-        }
-
-    }
-
-    public static class LeftInputAdapterNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public LeftInputAdapterNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-            String name;
-            String source;
-
-            if ( args.length == 1 ) {
-                String[] c = args[0].split( "," );
-                name = c[0].trim();
-                source = c[1].trim();
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
-            }
-            ObjectTypeNode otn = (ObjectTypeNode) context.get( source );
-
-            LeftInputAdapterNode liaNode = new LeftInputAdapterNode( buildContext.getNextId(),
-                                                                     otn,
-                                                                     buildContext );
-            liaNode.attach();
-            context.put( name,
-                         liaNode );
-        }
-    }
-
-    public static class BindingStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public BindingStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-            String name;
-            String index;
-            String type;
-            String field;
-
-            if ( args.length != 0 ) {
-                String[] c = args[0].split( "," );
-                if ( c.length == 3 ) {
-                    // TODO
-                    throw new IllegalArgumentException( "Cannot create Binding " + Arrays.asList( args ) );
-                } else {
-                    name = c[0].trim();
-                    index = c[1].trim();
-                    type = c[2].trim();
-                    field = c[3].trim();
-
-                    try {
-                        Pattern pattern = reteTesterHelper.getPattern( Integer.parseInt( index ),
-                                                                       type );
-
-                        final Class clazz = ((ClassObjectType) pattern.getObjectType()).getClassType();
-                        ClassFieldAccessorStore store = (ClassFieldAccessorStore) context.get( "ClassFieldAccessorStore" );
-
-                        final InternalReadAccessor extractor = store.getReader( clazz,
-                                                                                field,
-                                                                                getClass().getClassLoader() );
-
-                        Declaration declr = new Declaration( name,
-                                                             extractor,
-                                                             pattern );
-                        context.put( name,
-                                     declr );
-                    } catch ( Exception e ) {
-                        throw new IllegalArgumentException( "Cannot create Binding " + Arrays.asList( args,
-                                                                                                      e ) );
-                    }
-                }
-
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
-            }
-        }
-
-    }
-
-    public static class JoinNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public JoinNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-
-            if ( args.length != 0 ) {
-                String[] a = args[0].split( "," );
-                String name = a[0].trim();
-                String leftInput = a[1].trim();
-                String rightInput = a[2].trim();
-
-                LeftTupleSource leftTupleSource;
-                if ( "mock".equals( leftInput ) ) {
-                    leftTupleSource = new MockTupleSource( buildContext.getNextId() );
-                } else {
-                    leftTupleSource = (LeftTupleSource) context.get( leftInput );
-                }
-
-                ObjectSource rightObjectSource;
-                if ( "mock".equals( rightInput ) ) {
-                    rightObjectSource = new MockObjectSource( buildContext.getNextId() );
-                } else {
-                    rightObjectSource = (ObjectSource) context.get( rightInput );
-                }
-
-                a = args[1].split( "," );
-                String fieldName = a[0].trim();
-                String operator = a[1].trim();
-                String var = a[2].trim();
-
-                Declaration declr = (Declaration) context.get( var );
-
-                BetaNodeFieldConstraint betaConstraint;
-                try {
-                    betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
-                                                                                       fieldName,
-                                                                                       declr,
-                                                                                       operator );
-                } catch ( IntrospectionException e ) {
-                    throw new IllegalArgumentException();
-                }
-
-                SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
-                                                                               buildContext.getRuleBase().getConfiguration() );
-
-                JoinNode joinNode = new JoinNode( buildContext.getNextId(),
-                                                  leftTupleSource,
-                                                  rightObjectSource,
-                                                  constraints,
-                                                  BehaviorManager.NO_BEHAVIORS,
-                                                  buildContext );
-                joinNode.attach();
-                context.put( name,
-                             joinNode );
-
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + args );
-
-            }
-        }
-    }
-
-    public static class NotNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public NotNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-
-            if ( args.length != 0 ) {
-                String[] a = args[0].split( "," );
-                String name = a[0].trim();
-                String leftInput = a[1].trim();
-                String rightInput = a[2].trim();
-
-                LeftTupleSource leftTupleSource;
-                if ( "mock".equals( leftInput ) ) {
-                    leftTupleSource = new MockTupleSource( buildContext.getNextId() );
-                } else {
-                    leftTupleSource = (LeftTupleSource) context.get( leftInput );
-                }
-
-                ObjectSource rightObjectSource;
-                if ( "mock".equals( rightInput ) ) {
-                    rightObjectSource = new MockObjectSource( buildContext.getNextId() );
-                } else {
-                    rightObjectSource = (ObjectSource) context.get( rightInput );
-                }
-
-                a = args[1].split( "," );
-                String fieldName = a[0].trim();
-                String operator = a[1].trim();
-                String var = a[2].trim();
-
-                Declaration declr = (Declaration) context.get( var );
-
-                BetaNodeFieldConstraint betaConstraint;
-                try {
-                    betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
-                                                                                       fieldName,
-                                                                                       declr,
-                                                                                       operator );
-                } catch ( IntrospectionException e ) {
-                    throw new IllegalArgumentException();
-                }
-
-                SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
-                                                                               buildContext.getRuleBase().getConfiguration() );
-
-                NotNode notNode = new NotNode( buildContext.getNextId(),
-                                               leftTupleSource,
-                                               rightObjectSource,
-                                               constraints,
-                                               BehaviorManager.NO_BEHAVIORS,
-                                               buildContext );
-                notNode.attach();
-                context.put( name,
-                             notNode );
-
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + args );
-
-            }
-        }
-    }
-
-    public static class ForallNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public ForallNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-
-            if ( args.length != 0 ) {
-                //            String[] a = args[0].split( "," );
-                //            String name = a[0].trim();
-                //            String leftInput = a[1].trim();
-                //            String rightInput = a[2].trim();
-                //
-                //            LeftTupleSource leftTupleSource;
-                //            if ( "mock".equals( leftInput ) ) {
-                //                leftTupleSource = new MockTupleSource( buildContext.getNextId() );
-                //            } else {
-                //                leftTupleSource = (LeftTupleSource) context.get( leftInput );
-                //            }
-                //
-                //            ObjectSource rightObjectSource;
-                //            if ( "mock".equals( rightInput ) ) {
-                //                rightObjectSource = new MockObjectSource( buildContext.getNextId() );
-                //            } else {
-                //                rightObjectSource = (ObjectSource) context.get( rightInput );
-                //            }
-                //
-                //            a = args[1].split( "," );
-                //            String fieldName = a[0].trim();
-                //            String operator = a[1].trim();
-                //            String var = a[2].trim();
-                //
-                //            //Declaration declr = (Declaration) context.get( var );
-                //
-                //            BetaNodeFieldConstraint betaConstraint;
-                //            try {
-                //                betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
-                //                                                                                   fieldName,
-                //                                                                                   declr,
-                //                                                                                   operator );
-                //            } catch ( IntrospectionException e ) {
-                //                throw new IllegalArgumentException();
-                //            }
-                //
-                //            SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
-                //                                                                           buildContext.getRuleBase().getConfiguration() );
-                //            // * not*( $bus : Bus( ) and not ( Bus( this == $bus, color == RED ) ) )
-                //            
-                //            //new JoinNode()
-                //            
-                //            
-                //            
-                //            new ForallNotNode();
-                //            
-                ////            NotNode notNode = new NotNode( buildContext.getNextId(),
-                ////                                           leftTupleSource,
-                ////                                           rightObjectSource,
-                ////                                           constraints,
-                ////                                           BehaviorManager.NO_BEHAVIORS,
-                ////                                           buildContext );
-                ////            notNode.attach();
-                ////            context.put( name,
-                ////                         notNode );
-
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + args );
-
-            }
-        }
-    }
-
-    public static class ExistsNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public ExistsNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-
-            if ( args.length != 0 ) {
-                String[] a = args[0].split( "," );
-                String name = a[0].trim();
-                String leftInput = a[1].trim();
-                String rightInput = a[2].trim();
-
-                LeftTupleSource leftTupleSource;
-                if ( "mock".equals( leftInput ) ) {
-                    leftTupleSource = new MockTupleSource( buildContext.getNextId() );
-                } else {
-                    leftTupleSource = (LeftTupleSource) context.get( leftInput );
-                }
-
-                ObjectSource rightObjectSource;
-                if ( "mock".equals( rightInput ) ) {
-                    rightObjectSource = new MockObjectSource( buildContext.getNextId() );
-                } else {
-                    rightObjectSource = (ObjectSource) context.get( rightInput );
-                }
-
-                a = args[1].split( "," );
-                String fieldName = a[0].trim();
-                String operator = a[1].trim();
-                String var = a[2].trim();
-
-                Declaration declr = (Declaration) context.get( var );
-
-                BetaNodeFieldConstraint betaConstraint;
-                try {
-                    betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
-                                                                                       fieldName,
-                                                                                       declr,
-                                                                                       operator );
-                } catch ( IntrospectionException e ) {
-                    throw new IllegalArgumentException();
-                }
-
-                SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
-                                                                               buildContext.getRuleBase().getConfiguration() );
-
-                ExistsNode existsNode = new ExistsNode( buildContext.getNextId(),
-                                                        leftTupleSource,
-                                                        rightObjectSource,
-                                                        constraints,
-                                                        BehaviorManager.NO_BEHAVIORS,
-                                                        buildContext );
-                existsNode.attach();
-                context.put( name,
-                             existsNode );
-
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + args );
-
-            }
-        }
-    }
-
-    public static class RuleTerminalNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public RuleTerminalNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-
-            if ( args.length != 0 ) {
-                String[] a = args[0].split( "," );
-                String name = a[0].trim();
-                String leftInput = a[1].trim();
-
-                LeftTupleSource leftTupleSource;
-                if ( "mock".equals( leftInput ) ) {
-                    leftTupleSource = new MockTupleSource( buildContext.getNextId() );
-                } else {
-                    leftTupleSource = (LeftTupleSource) context.get( leftInput );
-                }
-
-                Rule rule = new Rule( name );
-
-                final RuleTerminalNode rtn = new InstrumentedRuleTerminalNode( buildContext.getNextId(),
-                                                                               leftTupleSource,
-                                                                               rule,
-                                                                               null,
-                                                                               buildContext );
-                Consequence consequence = new Consequence() {
-                    public void evaluate(KnowledgeHelper knowledgeHelper,
-                                         WorkingMemory workingMemory) throws Exception {
-
-                    }
-                };
-
-                rule.setConsequence( consequence );
-
-                rtn.attach();
-                context.put( name,
-                             rtn );
-
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + args );
-
-            }
-        }
-    }
-
-    public static class CollectNodeStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public CollectNodeStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-
-            if ( args.length != 0 ) {
-                String[] a = args[0].split( "," );
-                String name = a[0].trim();
-                String leftInput = a[1].trim();
-                String rightInput = a[2].trim();
-                String returnType = a[3].trim();
-
-                LeftTupleSource leftTupleSource;
-                if ( "mock".equals( leftInput ) ) {
-                    leftTupleSource = new MockTupleSource( buildContext.getNextId() );
-                } else {
-                    leftTupleSource = (LeftTupleSource) context.get( leftInput );
-                }
-
-                ObjectSource rightObjectSource;
-                if ( "mock".equals( rightInput ) ) {
-                    rightObjectSource = new MockObjectSource( buildContext.getNextId() );
-                } else {
-                    rightObjectSource = (ObjectSource) context.get( rightInput );
-                }
-
-                a = args[1].split( "," );
-                String fieldName = a[0].trim();
-                String operator = a[1].trim();
-                String var = a[2].trim();
-
-                Declaration declr = (Declaration) context.get( var );
-
-                BetaNodeFieldConstraint betaConstraint;
-                try {
-                    betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
-                                                                                       fieldName,
-                                                                                       declr,
-                                                                                       operator );
-                } catch ( IntrospectionException e ) {
-                    throw new IllegalArgumentException();
-                }
-
-                SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
-                                                                               buildContext.getRuleBase().getConfiguration() );
-
-                Pattern sourcePattern;
-                Pattern resultPattern;
-                try {
-                    sourcePattern = reteTesterHelper.getPattern( 0,
-                                                                 ((ClassObjectType) ((ObjectTypeNode) rightObjectSource).getObjectType()).getClassName() );
-                    resultPattern = reteTesterHelper.getPattern( buildContext.getNextId(),
-                                                                 returnType );
-                } catch ( Exception e ) {
-                    throw new IllegalArgumentException();
-                }
-
-                Collect collect = new Collect( sourcePattern,
-                                               resultPattern );
-
-                CollectNode collectNode = new CollectNode( buildContext.getNextId(),
-                                                           leftTupleSource,
-                                                           rightObjectSource,
-                                                           new AlphaNodeFieldConstraint[0],
-                                                           constraints,
-                                                           new EmptyBetaConstraints(),
-                                                           BehaviorManager.NO_BEHAVIORS,
-                                                           collect,
-                                                           false,
-                                                           buildContext );
-                collectNode.attach();
-                context.put( name,
-                             collectNode );
-
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + args );
-
-            }
-        }
-    }
-
-    public static class FactsStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public FactsStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-
-            if ( args.length >= 1 ) {
-
-                WorkingMemory wm = (WorkingMemory) context.get( "WorkingMemory" );
-                List<FactHandle> handles = (List<FactHandle>) context.get( "Handles" );
-                if ( handles == null ) {
-                    handles = new ArrayList<FactHandle>();
-                    context.put( "Handles",
-                                 handles );
-                }
-
-                for ( String str : args ) {
-                    List< ? > objects = (List< ? >) MVEL.eval( "[" + str + "]" );
-                    for ( Object object : objects ) {
-                        FactHandle handle = wm.insert( object );
-                        handles.add( handle );
-                    }
-                }
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
-            }
-        }
-    }
-
-    public static class WithStep
-        implements
-        Step {
-
-        private ReteTesterHelper reteTesterHelper;
-
-        public WithStep(ReteTesterHelper reteTesterHelper) {
-            this.reteTesterHelper = reteTesterHelper;
-        }
-
-        public void execute(Map<String, Object> context,
-                            String[] args) {
-            BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
-            List<InternalFactHandle> handles = (List<InternalFactHandle>) context.get( "Handles" );
-            Map<String, Object> vars = new HashMap<String, Object>();
-            vars.put( "h",
-                      handles );
-
-            if ( args.length >= 1 ) {
-                for ( String str : args ) {
-                    str = str.replaceAll( "h(\\d+)",
-                                          "h[$1]" ).trim();
-
-                    int spacePos = str.indexOf( ' ' );
-                    String handle = str.substring( 0,
-                                                   spacePos );
-                    String withStr = "with( " + handle + ".object ) { " + str.substring( spacePos + 1 ).trim() + "}";
-                    MVEL.eval( withStr,
-                               vars );
-                }
-                //            WorkingMemory wm = (WorkingMemory) context.get( "WorkingMemory" );
-                //            List handles = (List) context.get( "Handles" );
-                //            if ( handles == null ) {
-                //                handles = new ArrayList();
-                //                context.put( "Handles",
-                //                             handles );
-                //            }
-                //            
-                //            for ( String str : args ) {                
-                //                List objects  = ( List ) MVEL.eval(  "[" + str + "]" );
-                //                for ( Object object : objects ) {
-                //                    FactHandle handle = wm.insert( object );
-                //                    handles.add( handle );
-                //                }
-                //            }
-            } else {
-                throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
-            }
-        }
-    }
-
-    public static class ReteTesterHelper {
-
-        private Package                 pkg;
-        private ClassFieldAccessorStore store;
-        private EvaluatorRegistry       registry = new EvaluatorRegistry();
-        private final ClassTypeResolver typeResolver;
-
-        public ReteTesterHelper() {
-            this.pkg = new Package( "org.drools.examples.manners" );
-            this.pkg.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
-            this.store = this.pkg.getClassFieldAccessorStore();
-            this.store.setEagerWire( true );
-            this.typeResolver = new ClassTypeResolver( new HashSet<String>(),
-                                                       getClass().getClassLoader() );
-        }
-
-        public Package getPkg() {
-            return pkg;
-        }
-
-        public ClassFieldAccessorStore getStore() {
-            return store;
-        }
-
-        public EvaluatorRegistry getRegistry() {
-            return registry;
-        }
-
-        public BetaNodeFieldConstraint getBoundVariableConstraint(final Pattern pattern,
-                                                                  final String fieldName,
-                                                                  final Declaration declaration,
-                                                                  final String evaluatorString) throws IntrospectionException {
-            final Class clazz = ((ClassObjectType) pattern.getObjectType()).getClassType();
-
-            final InternalReadAccessor extractor = store.getReader( clazz,
-                                                                    fieldName,
-                                                                    getClass().getClassLoader() );
-
-            Evaluator evaluator = getEvaluator( clazz,
-                                                evaluatorString );
-
-            return new VariableConstraint( extractor,
-                                           declaration,
-                                           evaluator );
-        }
-
-        public Evaluator getEvaluator(Class cls,
-                                      String operator) {
-            return registry.getEvaluator( ValueType.determineValueType( cls ),
-                                          Operator.determineOperator( operator,
-                                                                      false ) );
-        }
-
-        public Pattern getPattern(int index,
-                                  String type) throws ClassNotFoundException {
-            Pattern pattern = new Pattern( index,
-                                           new ClassObjectType( typeResolver.resolveType( type ) ) );
-            return pattern;
-        }
-
-    }
-
-    public static class InstrumentedRuleTerminalNode extends RuleTerminalNode {
-
-        public InstrumentedRuleTerminalNode(final int id,
-                                            final LeftTupleSource source,
-                                            final Rule rule,
-                                            final GroupElement subrule,
-                                            final BuildContext context) {
-            super( id,
-                   source,
-                   rule,
-                   subrule,
-                   context );
-        }
-
-        @Override
-        public void assertLeftTuple(LeftTuple leftTuple,
-                                    PropagationContext context,
-                                    InternalWorkingMemory workingMemory) {
-            Set<LeftTuple> set = (Set<LeftTuple>) workingMemory.getNodeMemory( this );
-            set.add( leftTuple );
-            super.assertLeftTuple( leftTuple,
-                                   context,
-                                   workingMemory );
-        }
-
-        @Override
-        public void retractLeftTuple(LeftTuple leftTuple,
-                                     PropagationContext context,
-                                     InternalWorkingMemory workingMemory) {
-            Set<LeftTuple> set = (Set<LeftTuple>) workingMemory.getNodeMemory( this );
-            set.remove( leftTuple );
-            super.retractLeftTuple( leftTuple,
-                                    context,
-                                    workingMemory );
-        }
-
-        @Override
-        public Object createMemory(RuleBaseConfiguration config) {
-            return new LinkedHashSet<LeftTuple>();
-        }
-
-    }
 }
\ No newline at end of file

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineHelper.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineHelper.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineHelper.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -5,9 +5,10 @@
 import java.io.SequenceInputStream;
 import java.util.Arrays;
 
+import org.drools.reteoo.test.dsl.DslStep;
+
 import junit.framework.TestCase;
 
-import org.drools.reteoo.test.ReteDslTestEngine.DslStep;
 
 public class ReteDslTestEngineHelper {
     

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineTest.java	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineTest.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -29,7 +29,7 @@
 import org.drools.reteoo.ReteooRuleBase;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.reteoo.RuleTerminalNode;
-import org.drools.reteoo.test.ReteDslTestEngine.DslStep;
+import org.drools.reteoo.test.dsl.DslStep;
 import org.drools.rule.Declaration;
 import org.drools.spi.PropagationContext;
 

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/BindingStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/BindingStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/BindingStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.drools.base.ClassFieldAccessorStore;
+import org.drools.base.ClassObjectType;
+import org.drools.reteoo.builder.BuildContext;
+import org.drools.rule.Declaration;
+import org.drools.rule.Pattern;
+import org.drools.spi.InternalReadAccessor;
+
+public class BindingStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public BindingStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+        String name;
+        String index;
+        String type;
+        String field;
+
+        if ( args.length != 0 ) {
+            String[] c = args[0].split( "," );
+            if ( c.length == 3 ) {
+                // TODO
+                throw new IllegalArgumentException( "Cannot create Binding " + Arrays.asList( args ) );
+            } else {
+                name = c[0].trim();
+                index = c[1].trim();
+                type = c[2].trim();
+                field = c[3].trim();
+
+                try {
+                    Pattern pattern = reteTesterHelper.getPattern( Integer.parseInt( index ),
+                                                                   type );
+
+                    final Class clazz = ((ClassObjectType) pattern.getObjectType()).getClassType();
+                    ClassFieldAccessorStore store = (ClassFieldAccessorStore) context.get( "ClassFieldAccessorStore" );
+
+                    final InternalReadAccessor extractor = store.getReader( clazz,
+                                                                            field,
+                                                                            getClass().getClassLoader() );
+
+                    Declaration declr = new Declaration( name,
+                                                         extractor,
+                                                         pattern );
+                    context.put( name,
+                                 declr );
+                } catch ( Exception e ) {
+                    throw new IllegalArgumentException( "Cannot create Binding " + Arrays.asList( args,
+                                                                                                  e ),
+                                                        e );
+                }
+            }
+
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
+        }
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/BindingStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/CollectNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/CollectNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/CollectNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.beans.IntrospectionException;
+import java.util.Map;
+
+import org.drools.base.ClassObjectType;
+import org.drools.common.EmptyBetaConstraints;
+import org.drools.common.SingleBetaConstraints;
+import org.drools.reteoo.CollectNode;
+import org.drools.reteoo.LeftTupleSource;
+import org.drools.reteoo.MockObjectSource;
+import org.drools.reteoo.MockTupleSource;
+import org.drools.reteoo.ObjectSource;
+import org.drools.reteoo.ObjectTypeNode;
+import org.drools.reteoo.builder.BuildContext;
+import org.drools.rule.BehaviorManager;
+import org.drools.rule.Collect;
+import org.drools.rule.Declaration;
+import org.drools.rule.Pattern;
+import org.drools.spi.AlphaNodeFieldConstraint;
+import org.drools.spi.BetaNodeFieldConstraint;
+
+public class CollectNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public CollectNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+
+        if ( args.length != 0 ) {
+            String[] a = args[0].split( "," );
+            String name = a[0].trim();
+            String leftInput = a[1].trim();
+            String rightInput = a[2].trim();
+            String returnType = a[3].trim();
+
+            LeftTupleSource leftTupleSource;
+            if ( "mock".equals( leftInput ) ) {
+                leftTupleSource = new MockTupleSource( buildContext.getNextId() );
+            } else {
+                leftTupleSource = (LeftTupleSource) context.get( leftInput );
+            }
+
+            ObjectSource rightObjectSource;
+            if ( "mock".equals( rightInput ) ) {
+                rightObjectSource = new MockObjectSource( buildContext.getNextId() );
+            } else {
+                rightObjectSource = (ObjectSource) context.get( rightInput );
+            }
+
+            a = args[1].split( "," );
+            String fieldName = a[0].trim();
+            String operator = a[1].trim();
+            String var = a[2].trim();
+
+            Declaration declr = (Declaration) context.get( var );
+
+            Pattern sourcePattern;
+            Pattern resultPattern;
+            try {
+                sourcePattern = reteTesterHelper.getPattern( 0,
+                                                             ((ClassObjectType) ((ObjectTypeNode) rightObjectSource).getObjectType()).getClassName() );
+                resultPattern = reteTesterHelper.getPattern( buildContext.getNextId(),
+                                                             returnType );
+            } catch ( Exception e ) {
+                throw new IllegalArgumentException();
+            }
+
+            BetaNodeFieldConstraint betaConstraint;
+            try {
+                betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( sourcePattern,
+                                                                                   fieldName,
+                                                                                   declr,
+                                                                                   operator );
+            } catch ( IntrospectionException e ) {
+                throw new IllegalArgumentException();
+            }
+
+            SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
+                                                                           buildContext.getRuleBase().getConfiguration() );
+
+            Collect collect = new Collect( sourcePattern,
+                                           resultPattern );
+
+            CollectNode collectNode = new CollectNode( buildContext.getNextId(),
+                                                       leftTupleSource,
+                                                       rightObjectSource,
+                                                       new AlphaNodeFieldConstraint[0],
+                                                       constraints,
+                                                       new EmptyBetaConstraints(),
+                                                       BehaviorManager.NO_BEHAVIORS,
+                                                       collect,
+                                                       false,
+                                                       buildContext );
+            collectNode.attach();
+            context.put( name,
+                         collectNode );
+
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + args );
+
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/CollectNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/DslStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/DslStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/DslStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.List;
+
+public class DslStep {
+    private int          line;
+
+    private String       name;
+    private List<String> commands;
+
+    public DslStep(int line,
+                   String name,
+                   List<String> commands) {
+        this.line = line;
+        this.name = name;
+        this.commands = commands;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getLine() {
+        return line;
+    }
+
+    public List<String> getCommands() {
+        return commands;
+    }
+
+    public String toString() {
+        return line + " : " + name + " : " + commands;
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/DslStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ExistsNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ExistsNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ExistsNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.beans.IntrospectionException;
+import java.util.Map;
+
+import org.drools.common.SingleBetaConstraints;
+import org.drools.reteoo.ExistsNode;
+import org.drools.reteoo.LeftTupleSource;
+import org.drools.reteoo.MockObjectSource;
+import org.drools.reteoo.MockTupleSource;
+import org.drools.reteoo.ObjectSource;
+import org.drools.reteoo.builder.BuildContext;
+import org.drools.rule.BehaviorManager;
+import org.drools.rule.Declaration;
+import org.drools.spi.BetaNodeFieldConstraint;
+
+public class ExistsNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public ExistsNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+
+        if ( args.length != 0 ) {
+            String[] a = args[0].split( "," );
+            String name = a[0].trim();
+            String leftInput = a[1].trim();
+            String rightInput = a[2].trim();
+
+            LeftTupleSource leftTupleSource;
+            if ( "mock".equals( leftInput ) ) {
+                leftTupleSource = new MockTupleSource( buildContext.getNextId() );
+            } else {
+                leftTupleSource = (LeftTupleSource) context.get( leftInput );
+            }
+
+            ObjectSource rightObjectSource;
+            if ( "mock".equals( rightInput ) ) {
+                rightObjectSource = new MockObjectSource( buildContext.getNextId() );
+            } else {
+                rightObjectSource = (ObjectSource) context.get( rightInput );
+            }
+
+            a = args[1].split( "," );
+            String fieldName = a[0].trim();
+            String operator = a[1].trim();
+            String var = a[2].trim();
+
+            Declaration declr = (Declaration) context.get( var );
+
+            BetaNodeFieldConstraint betaConstraint;
+            try {
+                betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
+                                                                                   fieldName,
+                                                                                   declr,
+                                                                                   operator );
+            } catch ( IntrospectionException e ) {
+                throw new IllegalArgumentException();
+            }
+
+            SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
+                                                                           buildContext.getRuleBase().getConfiguration() );
+
+            ExistsNode existsNode = new ExistsNode( buildContext.getNextId(),
+                                                    leftTupleSource,
+                                                    rightObjectSource,
+                                                    constraints,
+                                                    BehaviorManager.NO_BEHAVIORS,
+                                                    buildContext );
+            existsNode.attach();
+            context.put( name,
+                         existsNode );
+
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + args );
+
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ExistsNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/FactsStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/FactsStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/FactsStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.FactHandle;
+import org.drools.WorkingMemory;
+import org.drools.reteoo.builder.BuildContext;
+import org.mvel2.MVEL;
+
+public class FactsStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public FactsStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+
+        if ( args.length >= 1 ) {
+
+            WorkingMemory wm = (WorkingMemory) context.get( "WorkingMemory" );
+            List<FactHandle> handles = (List<FactHandle>) context.get( "Handles" );
+            if ( handles == null ) {
+                handles = new ArrayList<FactHandle>();
+                context.put( "Handles",
+                             handles );
+            }
+
+            for ( String str : args ) {
+                List< ? > objects = (List< ? >) MVEL.eval( "[" + str + "]" );
+                for ( Object object : objects ) {
+                    FactHandle handle = wm.insert( object );
+                    handles.add( handle );
+                }
+            }
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/FactsStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ForallNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ForallNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ForallNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.Map;
+
+import org.drools.reteoo.builder.BuildContext;
+
+public class ForallNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public ForallNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+
+        if ( args.length != 0 ) {
+            //            String[] a = args[0].split( "," );
+            //            String name = a[0].trim();
+            //            String leftInput = a[1].trim();
+            //            String rightInput = a[2].trim();
+            //
+            //            LeftTupleSource leftTupleSource;
+            //            if ( "mock".equals( leftInput ) ) {
+            //                leftTupleSource = new MockTupleSource( buildContext.getNextId() );
+            //            } else {
+            //                leftTupleSource = (LeftTupleSource) context.get( leftInput );
+            //            }
+            //
+            //            ObjectSource rightObjectSource;
+            //            if ( "mock".equals( rightInput ) ) {
+            //                rightObjectSource = new MockObjectSource( buildContext.getNextId() );
+            //            } else {
+            //                rightObjectSource = (ObjectSource) context.get( rightInput );
+            //            }
+            //
+            //            a = args[1].split( "," );
+            //            String fieldName = a[0].trim();
+            //            String operator = a[1].trim();
+            //            String var = a[2].trim();
+            //
+            //            //Declaration declr = (Declaration) context.get( var );
+            //
+            //            BetaNodeFieldConstraint betaConstraint;
+            //            try {
+            //                betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
+            //                                                                                   fieldName,
+            //                                                                                   declr,
+            //                                                                                   operator );
+            //            } catch ( IntrospectionException e ) {
+            //                throw new IllegalArgumentException();
+            //            }
+            //
+            //            SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
+            //                                                                           buildContext.getRuleBase().getConfiguration() );
+            //            // * not*( $bus : Bus( ) and not ( Bus( this == $bus, color == RED ) ) )
+            //            
+            //            //new JoinNode()
+            //            
+            //            
+            //            
+            //            new ForallNotNode();
+            //            
+            ////            NotNode notNode = new NotNode( buildContext.getNextId(),
+            ////                                           leftTupleSource,
+            ////                                           rightObjectSource,
+            ////                                           constraints,
+            ////                                           BehaviorManager.NO_BEHAVIORS,
+            ////                                           buildContext );
+            ////            notNode.attach();
+            ////            context.put( name,
+            ////                         notNode );
+
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + args );
+
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ForallNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/JoinNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/JoinNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/JoinNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.beans.IntrospectionException;
+import java.util.Map;
+
+import org.drools.common.SingleBetaConstraints;
+import org.drools.reteoo.JoinNode;
+import org.drools.reteoo.LeftTupleSource;
+import org.drools.reteoo.MockObjectSource;
+import org.drools.reteoo.MockTupleSource;
+import org.drools.reteoo.ObjectSource;
+import org.drools.reteoo.builder.BuildContext;
+import org.drools.rule.BehaviorManager;
+import org.drools.rule.Declaration;
+import org.drools.spi.BetaNodeFieldConstraint;
+
+public class JoinNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public JoinNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+
+        if ( args.length != 0 ) {
+            String[] a = args[0].split( "," );
+            String name = a[0].trim();
+            String leftInput = a[1].trim();
+            String rightInput = a[2].trim();
+
+            LeftTupleSource leftTupleSource;
+            if ( "mock".equals( leftInput ) ) {
+                leftTupleSource = new MockTupleSource( buildContext.getNextId() );
+            } else {
+                leftTupleSource = (LeftTupleSource) context.get( leftInput );
+            }
+
+            ObjectSource rightObjectSource;
+            if ( "mock".equals( rightInput ) ) {
+                rightObjectSource = new MockObjectSource( buildContext.getNextId() );
+            } else {
+                rightObjectSource = (ObjectSource) context.get( rightInput );
+            }
+
+            a = args[1].split( "," );
+            String fieldName = a[0].trim();
+            String operator = a[1].trim();
+            String var = a[2].trim();
+
+            Declaration declr = (Declaration) context.get( var );
+
+            BetaNodeFieldConstraint betaConstraint;
+            try {
+                betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
+                                                                                   fieldName,
+                                                                                   declr,
+                                                                                   operator );
+            } catch ( IntrospectionException e ) {
+                throw new IllegalArgumentException();
+            }
+
+            SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
+                                                                           buildContext.getRuleBase().getConfiguration() );
+
+            JoinNode joinNode = new JoinNode( buildContext.getNextId(),
+                                              leftTupleSource,
+                                              rightObjectSource,
+                                              constraints,
+                                              BehaviorManager.NO_BEHAVIORS,
+                                              buildContext );
+            joinNode.attach();
+            context.put( name,
+                         joinNode );
+
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + args );
+
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/JoinNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftInputAdapterNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftInputAdapterNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftInputAdapterNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.drools.reteoo.LeftInputAdapterNode;
+import org.drools.reteoo.ObjectTypeNode;
+import org.drools.reteoo.builder.BuildContext;
+
+public class LeftInputAdapterNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public LeftInputAdapterNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+        String name;
+        String source;
+
+        if ( args.length == 1 ) {
+            String[] c = args[0].split( "," );
+            name = c[0].trim();
+            source = c[1].trim();
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
+        }
+        ObjectTypeNode otn = (ObjectTypeNode) context.get( source );
+
+        LeftInputAdapterNode liaNode = new LeftInputAdapterNode( buildContext.getNextId(),
+                                                                 otn,
+                                                                 buildContext );
+        liaNode.attach();
+        context.put( name,
+                     liaNode );
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftInputAdapterNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftTupleSinkStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftTupleSinkStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftTupleSinkStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.same;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.Map;
+
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.LeftTuple;
+import org.drools.reteoo.LeftTupleSink;
+import org.drools.reteoo.LeftTupleSource;
+import org.drools.spi.PropagationContext;
+import org.mockito.Mockito;
+import org.mockito.exceptions.base.MockitoAssertionError;
+
+public class LeftTupleSinkStep
+    implements
+    Step {
+
+    public LeftTupleSinkStep(ReteTesterHelper reteTesterHelper) {
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        if ( args.length != 0 ) {
+            String[] a = args[0].split( "," );
+            String name = a[0].trim();
+            String leftInput = a[1].trim();
+
+            LeftTupleSource leftTupleSource = (LeftTupleSource) context.get( leftInput );
+
+            LeftTupleSink mockedSink = Mockito.mock( LeftTupleSink.class );
+
+            leftTupleSource.addTupleSink( mockedSink );
+
+            context.put( name,
+                         mockedSink );
+
+        } else {
+            throw new IllegalArgumentException( "Cannot parse arguments " + args );
+
+        }
+    }
+
+    public void process(DslStep step,
+                        LeftTupleSink node,
+                        Map<String, Object> context,
+                        InternalWorkingMemory wm) {
+        try {
+            String[] cmds = step.getCommands().toArray( new String[0] );
+
+            for ( String cmd : cmds ) {
+                String[] args = cmd.trim().split( " " );
+                if ( args[0].equals( "verify" ) ) {
+                    int times = Integer.valueOf( args[1] );
+                    String method = args[2];
+
+                    try {
+                        if ( "assert".equals( method ) ) {
+                            verify( node,
+                                    times( times ) ).assertLeftTuple( any( LeftTuple.class ),
+                                                                      any( PropagationContext.class ),
+                                                                      same( wm ) );
+                        } else if ( "retract".equals( method ) ) {
+                            verify( node,
+                                    times( times ) ).retractLeftTuple( any( LeftTuple.class ),
+                                                                       any( PropagationContext.class ),
+                                                                       same( wm ) );
+                        } else if ( "modify".equals( method ) ) {
+                            verify( node,
+                                    times( times ) ).modifyLeftTuple( any( LeftTuple.class ),
+                                                                      any( PropagationContext.class ),
+                                                                      same( wm ) );
+                        } else {
+                            throw new IllegalArgumentException( "line " + step.getLine() + ": command does not exist " + cmd.trim() );
+                        }
+                    } catch ( MockitoAssertionError e ) {
+                        AssertionError ae = new AssertionError( "line " + step.getLine() + ": verify failed: " + e.getMessage() );
+                        ae.setStackTrace( e.getStackTrace() );
+                        throw ae;
+                    }
+                } else {
+                    throw new IllegalArgumentException( "line " + step.getLine() + ": command does not exist " + cmd.trim() );
+                }
+            }
+        } catch ( Exception e ) {
+            throw new IllegalArgumentException( "line " + step.getLine() + ": unable to execute step " + step,
+                                                e );
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/LeftTupleSinkStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NotNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NotNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NotNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.beans.IntrospectionException;
+import java.util.Map;
+
+import org.drools.common.SingleBetaConstraints;
+import org.drools.reteoo.LeftTupleSource;
+import org.drools.reteoo.MockObjectSource;
+import org.drools.reteoo.MockTupleSource;
+import org.drools.reteoo.NotNode;
+import org.drools.reteoo.ObjectSource;
+import org.drools.reteoo.builder.BuildContext;
+import org.drools.rule.BehaviorManager;
+import org.drools.rule.Declaration;
+import org.drools.spi.BetaNodeFieldConstraint;
+
+public class NotNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public NotNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+
+        if ( args.length != 0 ) {
+            String[] a = args[0].split( "," );
+            String name = a[0].trim();
+            String leftInput = a[1].trim();
+            String rightInput = a[2].trim();
+
+            LeftTupleSource leftTupleSource;
+            if ( "mock".equals( leftInput ) ) {
+                leftTupleSource = new MockTupleSource( buildContext.getNextId() );
+            } else {
+                leftTupleSource = (LeftTupleSource) context.get( leftInput );
+            }
+
+            ObjectSource rightObjectSource;
+            if ( "mock".equals( rightInput ) ) {
+                rightObjectSource = new MockObjectSource( buildContext.getNextId() );
+            } else {
+                rightObjectSource = (ObjectSource) context.get( rightInput );
+            }
+
+            a = args[1].split( "," );
+            String fieldName = a[0].trim();
+            String operator = a[1].trim();
+            String var = a[2].trim();
+
+            Declaration declr = (Declaration) context.get( var );
+
+            BetaNodeFieldConstraint betaConstraint;
+            try {
+                betaConstraint = this.reteTesterHelper.getBoundVariableConstraint( declr.getPattern(),
+                                                                                   fieldName,
+                                                                                   declr,
+                                                                                   operator );
+            } catch ( IntrospectionException e ) {
+                throw new IllegalArgumentException();
+            }
+
+            SingleBetaConstraints constraints = new SingleBetaConstraints( betaConstraint,
+                                                                           buildContext.getRuleBase().getConfiguration() );
+
+            NotNode notNode = new NotNode( buildContext.getNextId(),
+                                           leftTupleSource,
+                                           rightObjectSource,
+                                           constraints,
+                                           BehaviorManager.NO_BEHAVIORS,
+                                           buildContext );
+            notNode.attach();
+            context.put( name,
+                         notNode );
+
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + args );
+
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NotNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ObjectTypeNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ObjectTypeNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ObjectTypeNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.drools.base.ClassObjectType;
+import org.drools.reteoo.EntryPointNode;
+import org.drools.reteoo.ObjectTypeNode;
+import org.drools.reteoo.builder.BuildContext;
+
+public class ObjectTypeNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public ObjectTypeNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+        String name;
+        String type;
+
+        if ( args.length == 1 ) {
+            String[] c = args[0].split( "," );
+            name = c[0].trim();
+            type = c[1].trim();
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
+        }
+        ObjectTypeNode otn;
+        try {
+            EntryPointNode epn = new EntryPointNode( buildContext.getNextId(),
+                                                     buildContext.getRuleBase().getRete(),
+                                                     buildContext );
+            epn.attach();
+
+            otn = new ObjectTypeNode( buildContext.getNextId(),
+                                      epn,
+                                      new ClassObjectType( Class.forName( type ) ),
+                                      buildContext );
+            // we don't attach, as we want to manually propagate and not
+            // have the working memory propagate
+            //otn.attach();
+        } catch ( ClassNotFoundException e ) {
+            throw new IllegalArgumentException( "Cannot create OTN " + Arrays.asList( args,
+                                                                                      e ) );
+        }
+        context.put( name,
+                     otn );
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ObjectTypeNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ReteTesterHelper.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ReteTesterHelper.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ReteTesterHelper.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.beans.IntrospectionException;
+import java.util.HashSet;
+
+import org.drools.base.ClassFieldAccessorCache;
+import org.drools.base.ClassFieldAccessorStore;
+import org.drools.base.ClassObjectType;
+import org.drools.base.ClassTypeResolver;
+import org.drools.base.ValueType;
+import org.drools.base.evaluators.EvaluatorRegistry;
+import org.drools.base.evaluators.Operator;
+import org.drools.rule.Declaration;
+import org.drools.rule.Package;
+import org.drools.rule.Pattern;
+import org.drools.rule.VariableConstraint;
+import org.drools.spi.BetaNodeFieldConstraint;
+import org.drools.spi.Evaluator;
+import org.drools.spi.InternalReadAccessor;
+
+public class ReteTesterHelper {
+
+    private Package                 pkg;
+    private ClassFieldAccessorStore store;
+    private EvaluatorRegistry       registry = new EvaluatorRegistry();
+    private final ClassTypeResolver typeResolver;
+
+    public ReteTesterHelper() {
+        this.pkg = new Package( "org.drools.examples.manners" );
+        this.pkg.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
+        this.store = this.pkg.getClassFieldAccessorStore();
+        this.store.setEagerWire( true );
+        this.typeResolver = new ClassTypeResolver( new HashSet<String>(),
+                                                   getClass().getClassLoader() );
+    }
+
+    public Package getPkg() {
+        return pkg;
+    }
+
+    public ClassFieldAccessorStore getStore() {
+        return store;
+    }
+
+    public EvaluatorRegistry getRegistry() {
+        return registry;
+    }
+
+    public BetaNodeFieldConstraint getBoundVariableConstraint(final Pattern pattern,
+                                                              final String fieldName,
+                                                              final Declaration declaration,
+                                                              final String evaluatorString) throws IntrospectionException {
+        final Class clazz = ((ClassObjectType) pattern.getObjectType()).getClassType();
+
+        final InternalReadAccessor extractor = store.getReader( clazz,
+                                                                fieldName,
+                                                                getClass().getClassLoader() );
+
+        Evaluator evaluator = getEvaluator( clazz,
+                                            evaluatorString );
+
+        return new VariableConstraint( extractor,
+                                       declaration,
+                                       evaluator );
+    }
+
+    public Evaluator getEvaluator(Class cls,
+                                  String operator) {
+        return registry.getEvaluator( ValueType.determineValueType( cls ),
+                                      Operator.determineOperator( operator,
+                                                                  false ) );
+    }
+
+    public Pattern getPattern(int index,
+                              String type) throws ClassNotFoundException {
+        Pattern pattern = new Pattern( index,
+                                       new ClassObjectType( typeResolver.resolveType( type ) ) );
+        return pattern;
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ReteTesterHelper.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/RuleTerminalNodeStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/RuleTerminalNodeStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/RuleTerminalNodeStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.Map;
+
+import org.drools.WorkingMemory;
+import org.drools.reteoo.LeftTupleSource;
+import org.drools.reteoo.MockTupleSource;
+import org.drools.reteoo.RuleTerminalNode;
+import org.drools.reteoo.builder.BuildContext;
+import org.drools.reteoo.test.InstrumentedRuleTerminalNode;
+import org.drools.rule.Rule;
+import org.drools.spi.Consequence;
+import org.drools.spi.KnowledgeHelper;
+
+public class RuleTerminalNodeStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public RuleTerminalNodeStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+
+        if ( args.length != 0 ) {
+            String[] a = args[0].split( "," );
+            String name = a[0].trim();
+            String leftInput = a[1].trim();
+
+            LeftTupleSource leftTupleSource;
+            if ( "mock".equals( leftInput ) ) {
+                leftTupleSource = new MockTupleSource( buildContext.getNextId() );
+            } else {
+                leftTupleSource = (LeftTupleSource) context.get( leftInput );
+            }
+
+            Rule rule = new Rule( name );
+
+            final RuleTerminalNode rtn = new InstrumentedRuleTerminalNode( buildContext.getNextId(),
+                                                                           leftTupleSource,
+                                                                           rule,
+                                                                           null,
+                                                                           buildContext );
+            Consequence consequence = new Consequence() {
+                public void evaluate(KnowledgeHelper knowledgeHelper,
+                                     WorkingMemory workingMemory) throws Exception {
+
+                }
+            };
+
+            rule.setConsequence( consequence );
+
+            rtn.attach();
+            context.put( name,
+                         rtn );
+
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + args );
+
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/RuleTerminalNodeStep.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/Step.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/Step.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/Step.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.Map;
+
+public interface Step {
+    public void execute(Map<String, Object> context,
+                        String[] args);
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/Step.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/WithStep.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/WithStep.java	                        (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/WithStep.java	2010-01-11 02:34:14 UTC (rev 31001)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2008 Red Hat
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.reteoo.test.dsl;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.common.InternalFactHandle;
+import org.drools.reteoo.builder.BuildContext;
+import org.mvel2.MVEL;
+
+public class WithStep
+    implements
+    Step {
+
+    private ReteTesterHelper reteTesterHelper;
+
+    public WithStep(ReteTesterHelper reteTesterHelper) {
+        this.reteTesterHelper = reteTesterHelper;
+    }
+
+    public void execute(Map<String, Object> context,
+                        String[] args) {
+        BuildContext buildContext = (BuildContext) context.get( "BuildContext" );
+        List<InternalFactHandle> handles = (List<InternalFactHandle>) context.get( "Handles" );
+        Map<String, Object> vars = new HashMap<String, Object>();
+        vars.put( "h",
+                  handles );
+
+        if ( args.length >= 1 ) {
+            for ( String str : args ) {
+                str = str.replaceAll( "h(\\d+)",
+                                      "h[$1]" ).trim();
+
+                int spacePos = str.indexOf( ' ' );
+                String handle = str.substring( 0,
+                                               spacePos );
+                String withStr = "with( " + handle + ".object ) { " + str.substring( spacePos + 1 ).trim() + "}";
+                MVEL.eval( withStr,
+                           vars );
+            }
+            //            WorkingMemory wm = (WorkingMemory) context.get( "WorkingMemory" );
+            //            List handles = (List) context.get( "Handles" );
+            //            if ( handles == null ) {
+            //                handles = new ArrayList();
+            //                context.put( "Handles",
+            //                             handles );
+            //            }
+            //            
+            //            for ( String str : args ) {                
+            //                List objects  = ( List ) MVEL.eval(  "[" + str + "]" );
+            //                for ( Object object : objects ) {
+            //                    FactHandle handle = wm.insert( object );
+            //                    handles.add( handle );
+            //                }
+            //            }
+        } else {
+            throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/WithStep.java
___________________________________________________________________
Name: svn:executable
   + *

Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/CollectNodeAssertRetractTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/CollectNodeAssertRetractTest.data	2010-01-10 06:28:30 UTC (rev 31000)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/CollectNodeAssertRetractTest.data	2010-01-11 02:34:14 UTC (rev 31001)
@@ -9,63 +9,77 @@
 CollectNode
     col1, lian0, otnRight1, java.util.ArrayList
     type, ==, l1
+LeftTupleSink
+    sink1, col1
 Facts
-    new org.drools.Person('darth', 35), new org.drools.Person('bobba', 36)
-    new org.drools.Person('yoda', 37), new org.drools.Person('luke', 38)
-    new org.drools.Person('dave', 33), new org.drools.Person('bob', 32)       
+    new org.drools.Person('darth', 35, "brie"), new org.drools.Person('bobba', 36, 'stilton')
+    new org.drools.Cheese('brie', 10), new org.drools.Cheese('brie', 12)
+    new org.drools.Cheese('stilton', 15), new org.drools.Cheese('muzzarella', 12)
 
 /**
  * check single left assertion and retraction
  */
 assert
     otnLeft1 [h0]
-join1
+col1
     leftMemory [[h0]]
-join2
-    leftMemory []        
+sink1
+    verify 1 assert 
 retract
     otnLeft1 [h0]   
+col1
+    leftMemory []
+sink1
+    verify 1 retract
 /**    
  * check single right assertion and retraction
  */
 assert
-    otnRight1 [h1]
-join1
-    rightMemory [h1]
-join2
-    leftMemory []        
+    otnRight1 [h2]
+col1
+    rightMemory [h2]
 retract
-    otnRight1 [h1] 
+    otnRight1 [h2] 
+col1
+    rightMemory []
+sink1
+    verify 1 assert
+    verify 1 retract
 
 /**        
  *  check single left then right assertion
  */ 
 assert
     otnLeft1 [h0]  
-    otnRight1 [h1]
-join1
+    otnRight1 [h2]
+col1
     leftMemory [[h0]]  
-    rightMemory [h1]  
-join2
-    leftMemory [[h0, h1]] 
+    rightMemory [h2]  
+sink1 
+    verify 2 assert
+    verify 1 modify
 retract
     otnLeft1 [h0] 
-    otnRight1 [h1]
+    otnRight1 [h2]
+sink1 
+    verify 2 retract
    
 /**    
  *  check single right then left assertion
  */    
 assert
-    otnRight1 [h1]
-    otnLeft1 [h0]  
-join1
-    leftMemory [[h0]]  
-    rightMemory [h1]  
-join2
-    leftMemory [[h0, h1]] 
+    otnRight1 [h2]
+    otnLeft1 [h1]  
+col1
+    leftMemory [[h1]]  
+    rightMemory [h2]  
+sink1 
+    verify 3 assert
 retract
-    otnLeft1 [h0] 
-    otnRight1 [h1]    
+    otnLeft1 [h1] 
+    otnRight1 [h2]    
+sink1 
+    verify 3 retract
 
 /**    
  * assert two left and two right, with incremental first removal
@@ -73,39 +87,41 @@
 assert
     otnLeft1 [h0, h1]
     otnRight1 [h2, h3]
-join1
-    leftMemory [[h0], [h1]]  
+col1
+    leftMemory [[h0]]
+    leftMemory [[h1]]  
     rightMemory [h2, h3]  
-join2
-    leftMemory [[h0, h2], [h1, h2],
-                [h0, h3], [h1, h3]]        
+sink1 
+    verify 5 assert
+    verify 3 modify
 retract
     otnLeft1 [h0]
-join1
+col1
     leftMemory [[h1]]  
     rightMemory [h2, h3]  
-join2
-    leftMemory [[h1, h2],
-                [h1, h3]]               
+sink1 
+    verify 4 retract
 retract
     otnRight1 [h2]	
-join1
+col1
     leftMemory [[h1]]  
     rightMemory [h3]  
-join2
-    leftMemory [[h1, h3]]   
+sink1 
+    verify 4 retract
+    verify 3 modify
 retract
     otnLeft1 [h1] 
+sink1 
+    verify 5 retract
+retract
     otnRight1 [h3] 
-join1
+col1
     leftMemory []  
     rightMemory []  
-join2
-    leftMemory []
 
 /**    
  * assert two right and two left, with incremental last removal
- */
+ *
 assert
     otnRight1 [h2, h3]
     otnLeft1 [h0, h1]
@@ -140,7 +156,7 @@
 
 /**   
  * assert three left and three right, middle two are removed, and then iterated in reverse order
- */
+ *
 assert
     otnLeft1 [h0, h5, h2]
     otnRight1 [h3, h4, h1]
@@ -198,4 +214,4 @@
     rightMemory [h3, h1]          
 join2
     leftMemory [[h0, h3], [h2, h3],
-                [h0, h1], [h2, h1]]                             
\ No newline at end of file
+                [h0, h1], [h2, h1]]              */               
\ No newline at end of file



More information about the jboss-svn-commits mailing list