[jboss-svn-commits] JBL Code SVN: r31464 - in labs/jbossrules/branches/true_modify_20100104/drools-core/src: main/java/org/drools/marshalling/impl and 7 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Feb 5 18:45:04 EST 2010
Author: tirelli
Date: 2010-02-05 18:45:02 -0500 (Fri, 05 Feb 2010)
New Revision: 31464
Added:
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeSuiteTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestDef.java
Removed:
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeTestsSuite.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/NodeTest.java
Modified:
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/DisconnectedFactHandle.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/EventFactHandle.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
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/ConcurrentRightTuple.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EmptyLeftTupleSinkAdapter.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/FromNode.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/UnificationNode.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/rule/AgendaEventSupportTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockLeftTupleSink.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockRightTupleSink.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JUnitNodeTestRunner.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/ReteDslTestEngineTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCase.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCaseResult.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/parser/NodeTestDSLFactory.java
Log:
JBRULES-2339: JBRULES-2440: fixing tests for the merge
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/DisconnectedFactHandle.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/DisconnectedFactHandle.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/DisconnectedFactHandle.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -115,4 +115,34 @@
return "0:" + this.id + ":" + this.identityHashCode + ":" + this.objectHashCode + ":" + this.recency;
}
+
+ public LeftTuple getFirstLeftTuple() {
+ throw new UnsupportedOperationException( "DisonnectedFactHandle does not support this method" );
+ }
+
+
+ public RightTuple getFirstRightTuple() {
+ throw new UnsupportedOperationException( "DisonnectedFactHandle does not support this method" );
+ }
+
+
+ public RightTuple getLastRightTuple() {
+ throw new UnsupportedOperationException( "DisonnectedFactHandle does not support this method" );
+ }
+
+
+ public void setFirstRightTuple(RightTuple rightTuple) {
+ throw new UnsupportedOperationException( "DisonnectedFactHandle does not support this method" );
+ }
+
+
+ public void setLastLeftTuple(LeftTuple leftTuple) {
+ throw new UnsupportedOperationException( "DisonnectedFactHandle does not support this method" );
+ }
+
+
+ public void setLastRightTuple(RightTuple rightTuple) {
+ throw new UnsupportedOperationException( "DisonnectedFactHandle does not support this method" );
+ }
+
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/EventFactHandle.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/EventFactHandle.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/common/EventFactHandle.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -148,7 +148,9 @@
clone.setEntryPoint( getEntryPoint() );
clone.setEqualityKey( getEqualityKey() );
clone.setFirstLeftTuple( getLastLeftTuple() );
- clone.setRightTuple( getRightTuple() );
+ clone.setLastLeftTuple( getLastLeftTuple() );
+ clone.setFirstRightTuple( getFirstRightTuple() );
+ clone.setLastRightTuple( getLastRightTuple() );
clone.setObjectHashCode( getObjectHashCode() );
return clone;
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -366,7 +366,7 @@
ObjectOutputStream stream = context.stream;
// context.out.println( "RightTuples Start" );
- RightTuple rightTuple = handle.getRightTuple();
+ RightTuple rightTuple = handle.getFirstRightTuple();
for ( RightTuple tempRightTuple = rightTuple; tempRightTuple != null; tempRightTuple = (RightTuple) tempRightTuple.getHandleNext() ) {
rightTuple = tempRightTuple;
}
@@ -424,7 +424,7 @@
switch ( sink.getType() ) {
case NodeTypeEnums.JoinNode : {
// context.out.println( "JoinNode" );
- for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.getBetaChildren() ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
+ for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.firstChild ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
stream.writeShort( PersisterEnums.RIGHT_TUPLE );
stream.writeInt( childLeftTuple.getLeftTupleSink().getId() );
stream.writeInt( childLeftTuple.getRightParent().getFactHandle().getId() );
@@ -439,7 +439,7 @@
}
case NodeTypeEnums.EvalConditionNode : {
// context.out.println( "EvalConditionNode" );
- for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.getBetaChildren() ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
+ for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.firstChild ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
stream.writeShort( PersisterEnums.LEFT_TUPLE );
stream.writeInt( childLeftTuple.getLeftTupleSink().getId() );
writeLeftTuple( childLeftTuple,
@@ -455,7 +455,7 @@
// is not blocked so has children
stream.writeShort( PersisterEnums.LEFT_TUPLE_NOT_BLOCKED );
- for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.getBetaChildren() ); childLeftTuple != null; childLeftTuple = (LeftTuple) leftTuple.getLeftParentPrevious() ) {
+ for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.firstChild ); childLeftTuple != null; childLeftTuple = (LeftTuple) leftTuple.getLeftParentPrevious() ) {
stream.writeShort( PersisterEnums.LEFT_TUPLE );
stream.writeInt( childLeftTuple.getLeftTupleSink().getId() );
writeLeftTuple( childLeftTuple,
@@ -478,7 +478,7 @@
stream.writeShort( PersisterEnums.LEFT_TUPLE_BLOCKED );
stream.writeInt( leftTuple.getBlocker().getFactHandle().getId() );
- for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.getBetaChildren() ); childLeftTuple != null; childLeftTuple = (LeftTuple) leftTuple.getLeftParentPrevious() ) {
+ for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.firstChild ); childLeftTuple != null; childLeftTuple = (LeftTuple) leftTuple.getLeftParentPrevious() ) {
stream.writeShort( PersisterEnums.LEFT_TUPLE );
stream.writeInt( childLeftTuple.getLeftTupleSink().getId() );
writeLeftTuple( childLeftTuple,
@@ -505,7 +505,7 @@
stream.writeBoolean( accctx.propagated );
// then we serialize all the propagated tuples
- for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.getBetaChildren() ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
+ for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.firstChild ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
if( leftTuple.getLeftTupleSink().getId() == childLeftTuple.getLeftTupleSink().getId()) {
// this is a matching record, so, associate the right tuples
// context.out.println( "RightTuple(match) int:" + childLeftTuple.getLeftTupleSink().getId() + " int:" + childLeftTuple.getRightParent().getFactHandle().getId() );
@@ -539,7 +539,7 @@
stream.writeBoolean( colctx.propagated );
// then we serialize all the propagated tuples
- for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.getBetaChildren() ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
+ for ( LeftTuple childLeftTuple = getLeftTuple( leftTuple.firstChild ); childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentPrevious() ) {
if( leftTuple.getLeftTupleSink().getId() == childLeftTuple.getLeftTupleSink().getId()) {
// this is a matching record, so, associate the right tuples
// context.out.println( "RightTuple(match) int:" + childLeftTuple.getLeftTupleSink().getId() + " int:" + childLeftTuple.getRightParent().getFactHandle().getId() );
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -288,7 +288,6 @@
}
- @Override
public void modifyLeftTuple(LeftTuple leftTuple,
PropagationContext context,
InternalWorkingMemory workingMemory) {
@@ -389,7 +388,6 @@
accctx );
}
- @Override
public void modifyRightTuple(RightTuple rightTuple,
PropagationContext context,
InternalWorkingMemory workingMemory) {
@@ -566,7 +564,7 @@
// temporarily break the linked list to avoid wrong interactions
LeftTuple[] matchings = splitList( leftTuple,
- accctx );
+ accctx, false );
if ( accctx.propagated == true ) {
if ( isAllowed ) {
@@ -620,7 +618,8 @@
if ( accctx.propagated ) {
// temporarily break the linked list to avoid wrong interactions
LeftTuple[] matchings = splitList( leftTuple,
- accctx );
+ accctx,
+ true );
sink.assertLeftTuple( new LeftTuple( leftTuple,
accctx.result,
sink,
@@ -794,7 +793,7 @@
// so we just split the list keeping the head
LeftTuple[] matchings = splitList( leftTuple,
- accctx );
+ accctx, false );
for ( LeftTuple match = matchings[0]; match != null; match = match.getLeftParentNext() ) {
// no need to unlink from the left parent as the left parent is being wiped out
match.unlinkFromRightParent();
@@ -827,12 +826,14 @@
}
private LeftTuple[] splitList(final LeftTuple parent,
- final AccumulateContext accctx) {
+ final AccumulateContext accctx,
+ final boolean isUpdatingSink) {
LeftTuple[] matchings = new LeftTuple[2];
// save the matchings list
matchings[0] = getFirstMatch( parent,
- accctx );
+ accctx,
+ isUpdatingSink );
matchings[1] = parent.lastChild;
// update the tuple for the actual propagations
@@ -871,14 +872,16 @@
* @return
*/
private LeftTuple getFirstMatch(final LeftTuple leftTuple,
- final AccumulateContext accctx) {
+ final AccumulateContext accctx,
+ final boolean isUpdatingSink ) {
// unlink all right matches
LeftTuple child = leftTuple.firstChild;
if ( accctx.propagated ) {
// To do that, we need to skip the first N children that are in fact
// the propagated tuples
- for ( int i = 0; i < this.sink.size(); i++ ) {
+ int target = isUpdatingSink ? this.sink.size() - 1 : this.sink.size();
+ for ( int i = 0; i < target; i++ ) {
child = child.getLeftParentNext();
}
}
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-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -219,7 +219,7 @@
} else {
// if not propagated, just destroy the result fact handle
workingMemory.getFactHandleFactory().destroyFactHandle( colctx.resultTuple.getFactHandle() );
-
+
}
}
@@ -540,7 +540,8 @@
// temporarily break the linked list to avoid wrong interactions
LeftTuple[] matchings = splitList( leftTuple,
- colctx );
+ colctx,
+ false );
if ( colctx.propagated == true ) {
if ( isAllowed ) {
@@ -591,14 +592,16 @@
* @return
*/
private LeftTuple getFirstMatch(final LeftTuple leftTuple,
- final CollectContext colctx) {
+ final CollectContext colctx,
+ final boolean isUpdatingSink ) {
// unlink all right matches
LeftTuple child = leftTuple.firstChild;
if ( colctx.propagated ) {
// To do that, we need to skip the first N children that are in fact
// the propagated tuples
- for ( int i = 0; i < this.sink.size(); i++ ) {
+ int target = isUpdatingSink ? this.sink.size() - 1 : this.sink.size();
+ for ( int i = 0; i < target; i++ ) {
child = child.getLeftParentNext();
}
}
@@ -616,7 +619,8 @@
if ( colctx.propagated ) {
// temporarily break the linked list to avoid wrong interactions
LeftTuple[] matchings = splitList( leftTuple,
- colctx );
+ colctx,
+ true );
sink.assertLeftTuple( new LeftTuple( leftTuple,
colctx.resultTuple,
sink,
@@ -717,7 +721,8 @@
// so we just split the list keeping the head
LeftTuple[] matchings = splitList( leftTuple,
- colctx );
+ colctx,
+ false );
for ( LeftTuple match = matchings[0]; match != null; match = match.getLeftParentNext() ) {
// no need to unlink from the left parent as the left parent is being wiped out
match.unlinkFromRightParent();
@@ -747,12 +752,14 @@
}
private LeftTuple[] splitList(final LeftTuple parent,
- final CollectContext colctx) {
+ final CollectContext colctx,
+ final boolean isUpdatingSink) {
LeftTuple[] matchings = new LeftTuple[2];
// save the matchings list
matchings[0] = getFirstMatch( parent,
- colctx );
+ colctx,
+ isUpdatingSink );
matchings[1] = parent.lastChild;
// update the tuple for the actual propagations
@@ -761,7 +768,7 @@
parent.firstChild = null;
}
parent.lastChild = matchings[0].getLeftParentPrevious();
- if( parent.lastChild != null ) {
+ if ( parent.lastChild != null ) {
parent.lastChild.setLeftParentNext( null );
}
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/ConcurrentRightTuple.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/ConcurrentRightTuple.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/ConcurrentRightTuple.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -24,13 +24,13 @@
this.previous = new AtomicReference<Entry>();
this.next = new AtomicReference<Entry>();
- RightTuple currentFirst = handle.getRightTuple();
+ RightTuple currentFirst = handle.getFirstRightTuple();
if ( currentFirst != null ) {
currentFirst.setHandlePrevious( this );
setHandleNext( currentFirst );
}
- handle.setRightTuple( this );
+ handle.setFirstRightTuple( this );
}
public RightTupleList getMemory() {
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EmptyLeftTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EmptyLeftTupleSinkAdapter.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EmptyLeftTupleSinkAdapter.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -108,4 +108,16 @@
return null;
}
+ public void propagateModifyChildLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory,
+ boolean tupleMemoryEnabled) {
+ }
+
+ public void propagateModifyObject(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ }
+
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -23,6 +23,7 @@
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
+import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.common.PropagationContextImpl;
@@ -367,4 +368,19 @@
}
}
+ public void modifyLeftTuple(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void modifyLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/FromNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -328,4 +328,19 @@
}
}
}
+
+ public void modifyLeftTuple(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void modifyLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -92,7 +92,6 @@
/**
* @see org.drools.reteoo.ObjectSource#updateSink(org.drools.reteoo.ObjectSink, org.drools.spi.PropagationContext, org.drools.common.InternalWorkingMemory)
*/
- @Override
public void updateSink( ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory ) {
final PropagationQueueingNodeMemory memory = (PropagationQueueingNodeMemory) workingMemory
@@ -112,7 +111,6 @@
/**
* @see org.drools.common.BaseNode#attach()
*/
- @Override
public void attach() {
this.source.addObjectSink( this );
}
@@ -120,13 +118,11 @@
/**
* @see org.drools.common.BaseNode#attach(org.drools.common.InternalWorkingMemory[])
*/
- @Override
public void attach( InternalWorkingMemory[] workingMemories ) {
attach();
// this node does not require update, so nothing else to do.
}
- @Override
protected void doRemove( final RuleRemovalContext context, final ReteooBuilder builder, final BaseNode node,
final InternalWorkingMemory[] workingMemories ) {
if( !node.isInUse() ) {
@@ -344,10 +340,10 @@
public void execute( final ObjectSinkPropagator sink, final InternalWorkingMemory workingMemory ) {
for( RightTuple rightTuple = this.handle
- .getRightTuple(); rightTuple != null; rightTuple = (RightTuple) rightTuple.getHandleNext() ) {
+ .getFirstRightTuple(); rightTuple != null; rightTuple = (RightTuple) rightTuple.getHandleNext() ) {
rightTuple.getRightTupleSink().retractRightTuple( rightTuple, context, workingMemory );
}
- this.handle.setRightTuple( null );
+ this.handle.setFirstRightTuple( null );
for( LeftTuple leftTuple = this.handle.getLastLeftTuple(); leftTuple != null; leftTuple = (LeftTuple) leftTuple
.getLeftParentNext() ) {
@@ -398,4 +394,12 @@
this.node.propagateActions( workingMemory );
}
}
+
+ public void modifyObject(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -23,6 +23,7 @@
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
+import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.common.PropagationContextImpl;
@@ -270,6 +271,21 @@
public short getType() {
return NodeTypeEnums.QueryTerminalNode;
+ }
+
+ public void modifyLeftTuple(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void modifyLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
}
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -150,12 +150,12 @@
// retrieve handle from memory
final InternalFactHandle factHandle = (InternalFactHandle) memory.remove( tuple );
- for ( RightTuple rightTuple = factHandle.getRightTuple(); rightTuple != null; rightTuple = (RightTuple) rightTuple.getHandleNext() ) {
+ for ( RightTuple rightTuple = factHandle.getFirstRightTuple(); rightTuple != null; rightTuple = (RightTuple) rightTuple.getHandleNext() ) {
rightTuple.getRightTupleSink().retractRightTuple( rightTuple,
context,
workingMemory );
}
- factHandle.setRightTuple( null );
+ factHandle.setFirstRightTuple( null );
for ( LeftTuple leftTuple = factHandle.getLastLeftTuple(); leftTuple != null; leftTuple = (LeftTuple) leftTuple.getLeftParentNext() ) {
leftTuple.getLeftTupleSink().retractLeftTuple( leftTuple,
@@ -310,4 +310,19 @@
return this.tupleMemoryEnabled == other.tupleMemoryEnabled && this.tupleSource.equals( other.tupleSource );
}
+
+ public void modifyLeftTuple(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void modifyLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -276,7 +276,7 @@
InternalWorkingMemory workingMemory) {
LeftTuple leftTuple = modifyPreviousTuples.removeLeftTuple( this );
if ( leftTuple != null ) {
- leftTuple.reAddLeft(); //
+ leftTuple.reAdd(); //
// LeftTuple previously existed, so continue as modify
modifyLeftTuple( leftTuple,
context,
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/UnificationNode.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/UnificationNode.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/UnificationNode.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -2,6 +2,7 @@
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
+import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.spi.PropagationContext;
@@ -102,4 +103,12 @@
}
+ public void modifyLeftTuple(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Deleted: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -1,239 +0,0 @@
-package org.drools.event;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * 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.
- */
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.drools.Cheese;
-import org.drools.FactHandle;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.WorkingMemory;
-import org.drools.base.ClassFieldAccessorCache;
-import org.drools.base.ClassFieldReader;
-import org.drools.base.ClassObjectType;
-import org.drools.base.FieldFactory;
-import org.drools.base.ValueType;
-import org.drools.base.evaluators.ComparableEvaluatorsDefinition;
-import org.drools.base.evaluators.EqualityEvaluatorsDefinition;
-import org.drools.base.evaluators.EvaluatorRegistry;
-import org.drools.base.evaluators.MatchesEvaluatorsDefinition;
-import org.drools.base.evaluators.Operator;
-import org.drools.base.evaluators.SetEvaluatorsDefinition;
-import org.drools.base.evaluators.SoundslikeEvaluatorsDefinition;
-import org.drools.event.rule.ActivationCancelledCause;
-import org.drools.rule.LiteralConstraint;
-import org.drools.rule.Package;
-import org.drools.rule.Pattern;
-import org.drools.rule.Rule;
-import org.drools.spi.Consequence;
-import org.drools.spi.Evaluator;
-import org.drools.spi.FieldValue;
-import org.drools.spi.KnowledgeHelper;
-
-/**
- * @author <a href="mailto:simon at redhillconsulting.com.au">Simon Harris</a>
- */
-public class AgendaEventSupportTest extends TestCase {
-
- public static EvaluatorRegistry registry = new EvaluatorRegistry();
- static {
- registry.addEvaluatorDefinition( new EqualityEvaluatorsDefinition() );
- registry.addEvaluatorDefinition( new ComparableEvaluatorsDefinition() );
- registry.addEvaluatorDefinition( new SetEvaluatorsDefinition() );
- registry.addEvaluatorDefinition( new MatchesEvaluatorsDefinition() );
- registry.addEvaluatorDefinition( new SoundslikeEvaluatorsDefinition() );
- }
-
- public void testIsSerializable() {
- assertTrue( Serializable.class.isAssignableFrom( AgendaEventSupport.class ) );
- }
-
- public void testAgendaEventListener() throws Exception {
- final RuleBase rb = RuleBaseFactory.newRuleBase();
-
- // create a simpe package with one rule to test the events
- final Package pkg = new Package( "org.drools.test" );
- final Rule rule = new Rule( "test1" );
- rule.setAgendaGroup( "test group" );
- final ClassObjectType cheeseObjectType = new ClassObjectType( Cheese.class );
- final Pattern pattern = new Pattern( 0,
- cheeseObjectType );
-
- pkg.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
- pkg.getClassFieldAccessorStore().setEagerWire( true );
- final ClassFieldReader extractor = pkg.getClassFieldAccessorStore().getReader( Cheese.class,
- "type",
- getClass().getClassLoader() );
-
- final FieldValue field = FieldFactory.getFieldValue( "cheddar" );
-
- final Evaluator evaluator = registry.getEvaluator( ValueType.STRING_TYPE,
- Operator.EQUAL,
- null );
-
- final LiteralConstraint constraint = new LiteralConstraint( extractor,
- evaluator,
- field );
- pattern.addConstraint( constraint );
- rule.addPattern( pattern );
-
- rule.setConsequence( new Consequence() {
- public void evaluate(final KnowledgeHelper knowledgeHelper,
- final WorkingMemory workingMemory) throws Exception {
- }
-
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
-
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
-
- }
- } );
- pkg.addRule( rule );
- rb.addPackage( pkg );
-
- // create a new working memory and add an AgendaEventListener
- final WorkingMemory wm = rb.newStatefulSession();
- final List agendaList = new ArrayList();
- final AgendaEventListener agendaEventListener = new AgendaEventListener() {
-
- public void activationCancelled(ActivationCancelledEvent event,
- WorkingMemory workingMemory) {
- agendaList.add( event );
-
- }
-
- public void activationCreated(ActivationCreatedEvent event,
- WorkingMemory workingMemory) {
- agendaList.add( event );
- }
-
- public void afterActivationFired(AfterActivationFiredEvent event,
- WorkingMemory workingMemory) {
- agendaList.add( event );
- }
-
- public void agendaGroupPopped(AgendaGroupPoppedEvent event,
- WorkingMemory workingMemory) {
- agendaList.add( event );
- }
-
- public void agendaGroupPushed(AgendaGroupPushedEvent event,
- WorkingMemory workingMemory) {
- agendaList.add( event );
- }
-
- public void beforeActivationFired(BeforeActivationFiredEvent event,
- WorkingMemory workingMemory) {
- agendaList.add( event );
- }
- };
- wm.addEventListener( agendaEventListener );
-
- // assert the cheese fact
- final Cheese cheddar = new Cheese( "cheddar",
- 15 );
- FactHandle cheddarHandle = wm.insert( cheddar );
-
- // should be one ActivationCreatedEvent
- assertEquals( 1,
- agendaList.size() );
- ActivationCreatedEvent createdEvent = (ActivationCreatedEvent) agendaList.get( 0 );
- assertSame( cheddar,
- createdEvent.getActivation().getTuple().get( 0 ).getObject() );
-
- // clear the agenda to check CLEAR events occur
- wm.clearAgenda();
- ActivationCancelledEvent cancelledEvent = (ActivationCancelledEvent) agendaList.get( 1 );
- assertEquals( ActivationCancelledCause.CLEAR, cancelledEvent.getCause() );
-
- agendaList.clear();
-
- // update results in an ActivationCreatedEvent
- cheddar.setPrice( 14 );
- wm.update( cheddarHandle,
- cheddar );
- assertEquals( 1,
- agendaList.size() );
- createdEvent = (ActivationCreatedEvent) agendaList.get( 0 );
- assertSame( cheddar,
- createdEvent.getActivation().getTuple().get( 0 ).getObject() );
- agendaList.clear();
-
- // update results in a ActivationCancelledEvent and an ActivationCreatedEvent, note the object is always resolvable
- cheddar.setPrice( 14 );
- wm.update( cheddarHandle,
- cheddar );
- assertEquals( 2,
- agendaList.size() );
-
- cancelledEvent = (ActivationCancelledEvent) agendaList.get( 0 );
- assertEquals( ActivationCancelledCause.WME_MODIFY, cancelledEvent.getCause() );
- assertSame( cheddar,
- cancelledEvent.getActivation().getTuple().get( 0 ).getObject() );
- createdEvent = (ActivationCreatedEvent) agendaList.get( 1 );
- assertSame( cheddar,
- createdEvent.getActivation().getTuple().get( 0 ).getObject() );
- agendaList.clear();
-
- // retract results in a ActivationCancelledEvent, noe the object is not resolveable now as it no longer exists
- wm.retract( cheddarHandle );
- assertEquals( 1,
- agendaList.size() );
- cancelledEvent = (ActivationCancelledEvent) agendaList.get( 0 );
- assertNull( cancelledEvent.getActivation().getTuple().get( 0 ).getObject() );
-
- // re-assert the fact so we can test the agenda group events
- cheddarHandle = wm.insert( cheddar );
- agendaList.clear();
-
- // setFocus results in an AgendaGroupPushedEvent
- wm.setFocus( "test group" );
- assertEquals( 1,
- agendaList.size() );
- final AgendaGroupPushedEvent pushedEvent = (AgendaGroupPushedEvent) agendaList.get( 0 );
- assertEquals( "test group",
- pushedEvent.getAgendaGroup().getName() );
- agendaList.clear();
-
- // fireAllRules results in a BeforeActivationFiredEvent and an AfterActivationFiredEvent
- // the AgendaGroup becomes empty, which results in a popped event.
- wm.fireAllRules();
- assertEquals( 3,
- agendaList.size() );
- final BeforeActivationFiredEvent beforeEvent = (BeforeActivationFiredEvent) agendaList.get( 0 );
- assertSame( cheddar,
- beforeEvent.getActivation().getTuple().get( 0 ).getObject() );
- final AfterActivationFiredEvent afterEvent = (AfterActivationFiredEvent) agendaList.get( 1 );
- assertSame( cheddar,
- afterEvent.getActivation().getTuple().get( 0 ).getObject() );
- final AgendaGroupPoppedEvent poppedEvent = (AgendaGroupPoppedEvent) agendaList.get( 2 );
- assertEquals( "test group",
- poppedEvent.getAgendaGroup().getName() );
- }
-
-}
\ No newline at end of file
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/rule/AgendaEventSupportTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/rule/AgendaEventSupportTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/event/rule/AgendaEventSupportTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -187,20 +187,20 @@
createdEvent.getActivation().getFactHandles().toArray()[0] );
agendaList.clear();
- // update results in a ActivationCancelledEvent and an ActivationCreatedEvent, note the object is always resolvable
+ // update should not result in cancelation+activation events
cheddar.setPrice( 14 );
ksession.update( cheddarHandle,
cheddar );
- assertEquals( 2,
+ assertEquals( 0,
agendaList.size() );
- cancelledEvent = (ActivationCancelledEvent) agendaList.get( 0 );
- assertEquals( ActivationCancelledCause.WME_MODIFY, cancelledEvent.getCause() );
- assertSame( cheddarHandle,
- cancelledEvent.getActivation().getFactHandles().toArray()[0] );
- createdEvent = (ActivationCreatedEvent) agendaList.get( 1 );
- assertSame( cheddarHandle,
- createdEvent.getActivation().getFactHandles().toArray()[0] );
- agendaList.clear();
+ //cancelledEvent = (ActivationCancelledEvent) agendaList.get( 0 );
+ //assertEquals( ActivationCancelledCause.WME_MODIFY, cancelledEvent.getCause() );
+// assertSame( cheddarHandle,
+// cancelledEvent.getActivation().getFactHandles().toArray()[0] );
+// createdEvent = (ActivationCreatedEvent) agendaList.get( 1 );
+// assertSame( cheddarHandle,
+// createdEvent.getActivation().getFactHandles().toArray()[0] );
+// agendaList.clear();
// retract results in a ActivationCancelledEvent, note the object is not resolveable now as it no longer exists
ksession.retract( cheddarHandle );
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -23,7 +23,6 @@
import org.drools.base.ClassObjectType;
import org.drools.common.DefaultFactHandle;
import org.drools.common.EmptyBetaConstraints;
-import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.PropagationContextImpl;
import org.drools.reteoo.AccumulateNode.AccumulateMemory;
@@ -298,122 +297,6 @@
this.sink.getAsserted().size() );
}
- /**
- * Test method for {@link org.drools.reteoo.AccumulateNode#assertObject(InternalFactHandle, org.drools.spi.PropagationContext, InternalWorkingMemory)}.
- */
- public void testAssertObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
- null,
- null );
- final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
- null,
- null );
-
- final LeftTuple tuple0 = new LeftTuple( f0,
- null,
- true );
-
- // assert tuple, should add one to left memory
- this.node.assertLeftTuple( tuple0,
- this.context,
- this.workingMemory );
-
- // check memory
- assertEquals( 1,
- this.memory.getLeftTupleMemory().size() );
- assertEquals( 1,
- this.sink.getAsserted().size() );
- assertEquals( 0,
- this.accumulator.getMatchingObjects().size() );
-
- this.node.assertObject( f0,
- this.context,
- this.workingMemory );
- assertEquals( 1,
- this.memory.getRightTupleMemory().size() );
- assertEquals( 2,
- this.sink.getAsserted().size() );
- assertEquals( 1,
- this.accumulator.getMatchingObjects().size() );
-
- this.node.assertObject( f1,
- this.context,
- this.workingMemory );
-
- assertEquals( 2,
- this.memory.getRightTupleMemory().size() );
- assertEquals( 3,
- this.sink.getAsserted().size() );
- assertEquals( 2,
- this.accumulator.getMatchingObjects().size() );
-
- }
-
- /**
- * Test method for {@link org.drools.reteoo.AccumulateNode#retractObject(InternalFactHandle, org.drools.spi.PropagationContext, InternalWorkingMemory)}.
- */
- public void testRetractObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
- null,
- null );
- final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
- null,
- null );
-
- final LeftTuple tuple0 = new LeftTuple( f0,
- null,
- true );
-
- this.node.assertObject( f0,
- this.context,
- this.workingMemory );
- this.node.assertObject( f1,
- this.context,
- this.workingMemory );
- assertEquals( 2,
- this.memory.getRightTupleMemory().size() );
-
- // assert tuple, should add one to left memory
- this.node.assertLeftTuple( tuple0,
- this.context,
- this.workingMemory );
-
- // check memory
- assertEquals( 1,
- this.memory.getLeftTupleMemory().size() );
- assertEquals( 0,
- this.sink.getRetracted().size() );
- assertEquals( 1,
- this.sink.getAsserted().size() );
- assertEquals( 2,
- this.accumulator.getMatchingObjects().size() );
-
- this.node.retractRightTuple( f1.getRightTuple(),
- this.context,
- this.workingMemory );
- assertEquals( 1,
- this.memory.getRightTupleMemory().size() );
- assertEquals( 1,
- this.sink.getRetracted().size() );
- assertEquals( 2,
- this.sink.getAsserted().size() );
- assertEquals( 1,
- this.accumulator.getMatchingObjects().size() );
-
- this.node.retractRightTuple( f0.getRightTuple(),
- this.context,
- this.workingMemory );
- assertEquals( 0,
- this.memory.getRightTupleMemory().size() );
- assertEquals( 2,
- this.sink.getRetracted().size() );
- assertEquals( 3,
- this.sink.getAsserted().size() );
- assertEquals( 0,
- this.accumulator.getMatchingObjects().size() );
-
- }
-
public void testMemory() {
ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
BuildContext buildContext = new BuildContext( ruleBase,
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -288,121 +288,6 @@
this.sink.getAsserted().size() );
}
- public void testAssertObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
- null,
- null );
- final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
- null,
- null );
-
- final LeftTuple tuple0 = new LeftTuple( f0,
- this.node,
- true );
-
- // assert tuple, should add one to left memory
- this.node.assertLeftTuple( tuple0,
- this.contextAssert,
- this.workingMemory );
-
- // check memory
- assertEquals( 1,
- this.memory.betaMemory.getLeftTupleMemory().size() );
- assertEquals( 1,
- this.sink.getAsserted().size() );
- Assert.assertTrue( "An empty collection should be propagated",
- ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
-
- this.node.assertObject( f0,
- this.contextAssert,
- this.workingMemory );
- assertEquals( 1,
- this.memory.betaMemory.getRightTupleMemory().size() );
- assertEquals( 2,
- this.sink.getAsserted().size() );
- Assert.assertEquals( "Wrong number of elements in matching objects list ",
- 1,
- ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
-
- this.node.assertObject( f1,
- this.contextAssert,
- this.workingMemory );
-
- assertEquals( 2,
- this.memory.betaMemory.getRightTupleMemory().size() );
- assertEquals( 3,
- this.sink.getAsserted().size() );
- Assert.assertEquals( "Wrong number of elements in matching objects list ",
- 2,
- ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 2 ))[0]).get( 1 )).getObject()).size() );
-
- }
-
- public void testRetractObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
- null,
- null );
- final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
- null,
- null );
-
- final LeftTuple tuple0 = new LeftTuple( f0,
- this.node,
- true );
-
- this.node.assertObject( f0,
- this.contextAssert,
- this.workingMemory );
- this.node.assertObject( f1,
- this.contextAssert,
- this.workingMemory );
- assertEquals( 2,
- this.memory.betaMemory.getRightTupleMemory().size() );
-
- // assert tuple, should add one to left memory
- this.node.assertLeftTuple( tuple0,
- this.contextAssert,
- this.workingMemory );
-
- // check memory
- assertEquals( 1,
- this.memory.betaMemory.getLeftTupleMemory().size() );
- assertEquals( 0,
- this.sink.getRetracted().size() );
- assertEquals( 1,
- this.sink.getAsserted().size() );
- Assert.assertEquals( "Wrong number of elements in matching objects list ",
- 2,
- ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
-
- this.node.retractRightTuple( f1.getRightTuple(),
- this.contextRetract,
- this.workingMemory );
- assertEquals( 1,
- this.memory.betaMemory.getRightTupleMemory().size() );
- assertEquals( 1,
- this.sink.getRetracted().size() );
- assertEquals( 2,
- this.sink.getAsserted().size() );
- Assert.assertEquals( "Wrong number of elements in matching objects list ",
- 1,
- ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
-
- this.node.retractRightTuple( f0.getRightTuple(),
- this.contextRetract,
- this.workingMemory );
- assertEquals( 0,
- this.memory.betaMemory.getRightTupleMemory().size() );
- assertEquals( 2,
- this.sink.getRetracted().size() );
- assertEquals( 3,
- this.sink.getAsserted().size() );
- Assert.assertEquals( "Wrong number of elements in matching objects list ",
- 0,
- ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 2 ))[0]).get( 1 )).getObject()).size() );
-
- }
-
public void testMemory() {
ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
BuildContext buildContext = new BuildContext( ruleBase,
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -627,5 +627,19 @@
// TODO Auto-generated method stub
return 0;
}
+
+ public void modifyLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void modifyRightTuple(RightTuple rightTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
}
}
Deleted: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -1,399 +0,0 @@
-/*
- * Copyright 2006 JBoss Inc
- *
- * 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;
-
-import java.beans.IntrospectionException;
-
-import org.drools.Cheese;
-import org.drools.DroolsTestCase;
-import org.drools.FactException;
-import org.drools.RuleBaseConfiguration;
-import org.drools.RuleBaseFactory;
-import org.drools.common.DefaultBetaConstraints;
-import org.drools.common.DefaultFactHandle;
-import org.drools.common.InternalFactHandle;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.common.PropagationContextImpl;
-import org.drools.reteoo.builder.BuildContext;
-import org.drools.rule.Behavior;
-import org.drools.rule.ContextEntry;
-import org.drools.rule.Rule;
-import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.PropagationContext;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-
-/**
- * @author etirelli
- *
- */
-public class ExistsNodeTest extends DroolsTestCase {
- private final Mockery mockery = new Mockery();
-
- Rule rule;
- PropagationContext context;
- ReteooWorkingMemory workingMemory;
- MockObjectSource objectSource;
- MockTupleSource tupleSource;
- MockLeftTupleSink sink;
- ExistsNode node;
- RightInputAdapterNode ria;
- BetaMemory memory;
- BetaNodeFieldConstraint constraint;
-
- /**
- * Setup the BetaNode used in each of the tests
- * @throws IntrospectionException
- */
- public void setUp() throws IntrospectionException {
- // create mock objects
- constraint = mockery.mock( BetaNodeFieldConstraint.class );
- final ContextEntry c = mockery.mock( ContextEntry.class );
-
- // set mock objects expectations
- mockery.checking( new Expectations() {
- {
- // allowed calls and return values
- allowing( constraint ).createContextEntry();
- will( returnValue( c ) );
-
- allowing( c ).updateFromFactHandle( with( any( InternalWorkingMemory.class ) ),
- with( any( InternalFactHandle.class ) ) );
- allowing( c ).updateFromTuple( with( any( InternalWorkingMemory.class ) ),
- with( any( LeftTuple.class ) ) );
- allowing( c ).resetTuple();
- allowing( c ).resetFactHandle();
- }
- } );
-
- this.rule = new Rule( "test-rule" );
- this.context = new PropagationContextImpl( 0,
- PropagationContext.ASSERTION,
- null,
- null,
- null );
-
- ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
- BuildContext buildContext = new BuildContext( ruleBase,
- ruleBase.getReteooBuilder().getIdGenerator() );
-
- this.workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
-
- final RuleBaseConfiguration configuration = new RuleBaseConfiguration();
-
- // string1Declaration is bound to pattern 3
- this.node = new ExistsNode( 15,
- new MockTupleSource( 5 ),
- new MockObjectSource( 8 ),
- new DefaultBetaConstraints( new BetaNodeFieldConstraint[]{this.constraint},
- configuration ),
- Behavior.EMPTY_BEHAVIOR_LIST,
- buildContext );
-
- this.sink = new MockLeftTupleSink();
- this.node.addTupleSink( this.sink );
-
- this.memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
- }
-
- /**
- * Test assertion with both Objects and Tuples
- *
- * @throws AssertionException
- */
- public void testExistsStandard() throws FactException {
- // set mock objects expectations
- mockery.checking( new Expectations() {
- {
- // allowed calls and return values
- allowing( constraint ).isAllowedCachedLeft( with( any( ContextEntry.class ) ),
- with( any( InternalFactHandle.class ) ) );
- will( returnValue( true ) );
-
- allowing( constraint ).isAllowedCachedRight( with( any( LeftTuple.class ) ),
- with( any( ContextEntry.class ) ) );
- will( returnValue( true ) );
- }
- } );
-
- // assert tuple
- final Cheese cheddar = new Cheese( "cheddar",
- 10 );
- final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.insert( cheddar );
-
- final LeftTuple tuple1 = new LeftTuple( f0,
- this.node,
- true );
-
- this.node.assertLeftTuple( tuple1,
- this.context,
- this.workingMemory );
-
- // no matching objects, so should not propagate
- assertLength( 0,
- this.sink.getAsserted() );
-
- assertLength( 0,
- this.sink.getRetracted() );
-
- // LeftTuple is not matched so should still be in memory
- assertEquals( 1,
- this.memory.getLeftTupleMemory().size() );
-
- // assert will match, so should propagate
- final Cheese brie = new Cheese( "brie",
- 10 );
- final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.insert( brie );
-
- this.node.assertObject( f1,
- this.context,
- this.workingMemory );
-
- // LeftTuple is now matched so should not be in memory
- assertEquals( 0,
- this.memory.getLeftTupleMemory().size() );
-
- // check a single assertion
- assertLength( 1,
- this.sink.getAsserted() );
-
- assertLength( 0,
- this.sink.getRetracted() );
-
- assertEquals( new LeftTuple( f0,
- this.sink,
- true ),
- ((Object[]) this.sink.getAsserted().get( 0 ))[0] );
-
- // assert tuple, will have matches, so propagate
- final DefaultFactHandle f2 = (DefaultFactHandle) this.workingMemory.insert( new Cheese( "gouda",
- 10 ) );
- final LeftTuple tuple2 = new LeftTuple( f2,
- this.node,
- true );
- this.node.assertLeftTuple( tuple2,
- this.context,
- this.workingMemory );
-
- // check propagations
- assertLength( 2,
- this.sink.getAsserted() );
-
- assertLength( 0,
- this.sink.getRetracted() );
-
- // both LeftTuples should match, so no LeftTupleMemory
- assertEquals( 0,
- this.memory.getLeftTupleMemory().size() );
- assertEquals( 1,
- this.memory.getRightTupleMemory().size() );
-
- // When this is retracter both tuples should be retracted
- this.node.retractRightTuple( f1.getRightTuple(),
- this.context,
- this.workingMemory );
-
- // both LeftTuples are no longer matched, so should have LeftTupleMemory
- assertEquals( 2,
- this.memory.getLeftTupleMemory().size() );
-
- // check retracts
- assertLength( 2,
- this.sink.getAsserted() );
-
- assertLength( 2,
- this.sink.getRetracted() );
- }
-
- /**
- * Test assertion with both Objects and Tuples
- *
- * @throws AssertionException
- */
- public void testExistsWithConstraints() throws FactException {
- // set mock objects expectations
- mockery.checking( new Expectations() {
- {
- // allowed calls and return values
- allowing( constraint ).isAllowedCachedLeft( with( any( ContextEntry.class ) ),
- with( any( InternalFactHandle.class ) ) );
- will( returnValue( false ) );
- allowing( constraint ).isAllowedCachedRight( with( any( LeftTuple.class ) ),
- with( any( ContextEntry.class ) ) );
- will( returnValue( false ) );
- }
- } );
-
- // assert tuple
- final Cheese cheddar = new Cheese( "cheddar",
- 10 );
- final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.insert( cheddar );
-
- final LeftTuple tuple1 = new LeftTuple( f0,
- this.node,
- true );
-
- this.node.assertLeftTuple( tuple1,
- this.context,
- this.workingMemory );
-
- // no matching objects, so don't propagate
- assertLength( 0,
- this.sink.getAsserted() );
-
- assertLength( 0,
- this.sink.getRetracted() );
-
- // assert will not match, so activation should stay propagated
- final Cheese brie = new Cheese( "brie",
- 10 );
- final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.insert( brie );
-
- this.node.assertObject( f1,
- this.context,
- this.workingMemory );
-
- // no matches, so no propagations still
- assertLength( 0,
- this.sink.getAsserted() );
-
- assertLength( 0,
- this.sink.getRetracted() );
-
- // assert tuple, will have matches, so do assert propagation
- final DefaultFactHandle f2 = (DefaultFactHandle) this.workingMemory.insert( new Cheese( "gouda",
- 10 ) );
- final LeftTuple tuple2 = new LeftTuple( f2,
- this.node,
- true );
- this.node.assertLeftTuple( tuple2,
- this.context,
- this.workingMemory );
-
- assertLength( 0,
- this.sink.getAsserted() );
-
- assertLength( 0,
- this.sink.getRetracted() );
- }
-
- /**
- * Tests memory consistency after insert/update/retract calls
- *
- * @throws AssertionException
- */
- public void testExistsMemoryManagement() throws FactException {
- // set mock objects expectations
- mockery.checking( new Expectations() {
- {
- // allowed calls and return values
- allowing( constraint ).isAllowedCachedLeft( with( any( ContextEntry.class ) ),
- with( any( InternalFactHandle.class ) ) );
- will( returnValue( true ) );
- allowing( constraint ).isAllowedCachedRight( with( any( LeftTuple.class ) ),
- with( any( ContextEntry.class ) ) );
- will( returnValue( true ) );
- }
- } );
-
- // assert tuple
- final Cheese cheddar = new Cheese( "cheddar",
- 10 );
- final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.insert( cheddar );
- final LeftTuple tuple1 = new LeftTuple( f0,
- this.node,
- true );
-
- this.node.assertLeftTuple( tuple1,
- this.context,
- this.workingMemory );
-
- // not blocked, so should be in memory
- assertEquals( 1,
- this.memory.getLeftTupleMemory().size() );
-
- // assert will match, so should propagate
- final Cheese brie = new Cheese( "brie",
- 10 );
- final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.insert( brie );
-
- // Initially, no objects in right memory
- assertEquals( 0,
- this.memory.getRightTupleMemory().size() );
- this.node.assertObject( f1,
- this.context,
- this.workingMemory );
-
- // blocked, so should not be in memory
- assertEquals( 0,
- this.memory.getLeftTupleMemory().size() );
-
- // Now, needs to have 1 object in right memory
- assertEquals( 1,
- this.memory.getRightTupleMemory().size() );
-
- // simulate modify
- this.node.retractRightTuple( f1.getRightTuple(),
- this.context,
- this.workingMemory );
-
- // not blocked, so should be in memory
- assertEquals( 1,
- this.memory.getLeftTupleMemory().size() );
-
- this.node.assertObject( f1,
- this.context,
- this.workingMemory );
-
- // blocked again, so should not be in memory
- assertEquals( 0,
- this.memory.getLeftTupleMemory().size() );
-
- // Memory should not change
- assertEquals( 1,
- this.memory.getRightTupleMemory().size() );
-
- // When this is retracter the tuple should assert
- this.node.retractRightTuple( f1.getRightTuple(),
- this.context,
- this.workingMemory );
- assertEquals( 0,
- this.memory.getRightTupleMemory().size() );
-
- // not blocked, so should be in memory
- assertEquals( 1,
- this.memory.getLeftTupleMemory().size() );
-
- // simulate modify
- this.node.retractLeftTuple( tuple1,
- this.context,
- this.workingMemory );
- assertEquals( 0,
- this.memory.getLeftTupleMemory().size() );
- this.node.assertLeftTuple( tuple1,
- this.context,
- this.workingMemory );
- assertEquals( 1,
- this.memory.getLeftTupleMemory().size() );
- this.node.retractLeftTuple( tuple1,
- this.context,
- this.workingMemory );
- assertEquals( 0,
- this.memory.getLeftTupleMemory().size() );
- }
-
-}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -315,18 +315,18 @@
assertEquals( 1,
memory.betaMemory.getLeftTupleMemory().size() );
assertNull( memory.betaMemory.getRightTupleMemory() );
- RightTuple rightTuple2 = tuple.getBetaChildren().getRightParent();
- RightTuple rightTuple1= tuple.getBetaChildren().getLeftParentNext().getRightParent();
+ RightTuple rightTuple2 = tuple.firstChild.getRightParent();
+ RightTuple rightTuple1= tuple.firstChild.getLeftParentNext().getRightParent();
assertFalse( rightTuple1.equals( rightTuple2 ) );
- assertNull( tuple.getBetaChildren().getLeftParentNext().getLeftParentNext() );
+ assertNull( tuple.firstChild.getLeftParentNext().getLeftParentNext() );
final InternalFactHandle handle2 = rightTuple2.getFactHandle();
final InternalFactHandle handle1 = rightTuple1.getFactHandle();
assertEquals( handle1.getObject(),
+ cheese2 );
+ assertEquals( handle2.getObject(),
cheese1 );
- assertEquals( handle2.getObject(),
- cheese2 );
from.retractLeftTuple( tuple,
context,
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockLeftTupleSink.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockLeftTupleSink.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockLeftTupleSink.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -24,6 +24,7 @@
import org.drools.FactException;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
+import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.common.RuleBasePartitionId;
@@ -160,7 +161,6 @@
}
- @Override
public void networkUpdated() {
// TODO Auto-generated method stub
@@ -171,4 +171,19 @@
return 0;
}
+ public void modifyLeftTuple(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void modifyLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -125,4 +125,19 @@
// TODO Auto-generated method stub
return NodeTypeEnums.JoinNode;
}
+
+ public void modifyObject(InternalFactHandle factHandle,
+ ModifyPreviousTuples modifyPreviousTuples,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void modifyRightTuple(RightTuple rightTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockRightTupleSink.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockRightTupleSink.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/MockRightTupleSink.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -46,4 +46,11 @@
public short getType() {
return NodeTypeEnums.JoinNode;
}
+
+ public void modifyRightTuple(RightTuple rightTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -216,7 +216,7 @@
this.memory.getRightTupleMemory().size() );
// When this is retracted both tuples should assert
- this.node.retractRightTuple( f1.getRightTuple(),
+ this.node.retractRightTuple( f1.firstRightTuple,
this.context,
this.workingMemory );
@@ -361,7 +361,7 @@
this.memory.getRightTupleMemory().size() );
// simulate modify
- this.node.retractRightTuple( f1.getRightTuple(),
+ this.node.retractRightTuple( f1.firstRightTuple,
this.context,
this.workingMemory );
this.node.assertObject( f1,
@@ -372,7 +372,7 @@
this.memory.getRightTupleMemory().size() );
// When this is retracter both tuples should assert
- this.node.retractRightTuple( f1.getRightTuple(),
+ this.node.retractRightTuple( f1.firstRightTuple,
this.context,
this.workingMemory );
assertEquals( 0,
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JUnitNodeTestRunner.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JUnitNodeTestRunner.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JUnitNodeTestRunner.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -16,11 +16,11 @@
*/
package org.drools.reteoo.test;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.drools.reteoo.test.dsl.NodeTest;
+import org.drools.RuntimeDroolsException;
+import org.drools.reteoo.test.dsl.NodeTestDef;
import org.drools.reteoo.test.dsl.NodeTestCase;
import org.junit.runner.Description;
import org.junit.runner.Runner;
@@ -37,16 +37,21 @@
private Description descr;
private List<NodeTestCase> testCases = new ArrayList<NodeTestCase>();
- public JUnitNodeTestRunner(Class< ? > clazz) throws Exception {
- NodeTestCasesSource ntsuite = (NodeTestCasesSource) clazz.newInstance();
- testCases = ntsuite.getTestCases();
+ public JUnitNodeTestRunner(Class< ? > clazz) {
+ try {
+ NodeTestCasesSource ntsuite = (NodeTestCasesSource) clazz.newInstance();
+ testCases = ntsuite.getTestCases();
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ throw new RuntimeDroolsException( "Error instantiating node test runner: "+e, e );
+ }
this.descr = Description.createSuiteDescription( "Node test case suite" );
for ( NodeTestCase tcase : testCases ) {
Description tcaseDescr = Description.createSuiteDescription( tcase.getName() );
tcase.setDescription( tcaseDescr );
this.descr.addChild( tcaseDescr );
- for ( NodeTest ntest : tcase.getTests() ) {
+ for ( NodeTestDef ntest : tcase.getTests() ) {
Description ntestDescr = Description.createTestDescription( clazz,
ntest.getName() );
tcaseDescr.addChild( ntestDescr );
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeSuiteTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeSuiteTest.java (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeSuiteTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -0,0 +1,63 @@
+/*
+ * 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.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.reteoo.test.dsl.NodeTestCase;
+import org.junit.runner.RunWith;
+
+/**
+ * A test case suite to manage and run all node test cases
+ *
+ * @author etirelli
+ */
+ at RunWith(JUnitNodeTestRunner.class)
+public class NodeSuiteTest
+ implements
+ NodeTestCasesSource {
+
+ /* (non-Javadoc)
+ * @see org.drools.reteoo.test.NodeTestCasesSource#getTestCases()
+ */
+ public List<NodeTestCase> getTestCases() throws Exception {
+ List<NodeTestCase> result = new ArrayList<NodeTestCase>();
+ File base = new File( this.getClass().getResource( "." ).toURI() );
+ for ( File file : base.listFiles( new FilenameFilter() {
+ public boolean accept(File arg0,
+ String arg1) {
+ return arg1.endsWith( ".nodeTestCase" );
+ }
+ } ) ) {
+ InputStream is = new FileInputStream( file );
+ NodeTestCase tcase = ReteDslTestEngine.compile( is );
+ if ( tcase.hasErrors() ) {
+ throw new IllegalArgumentException( "Error parsing and loading testcase: " + file.getAbsolutePath() + "\n" + tcase.getErrors().toString() );
+ }
+ result.add( tcase );
+ is.close();
+ }
+
+ return result;
+ }
+
+}
Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeSuiteTest.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeTestsSuite.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeTestsSuite.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NodeTestsSuite.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -1,64 +0,0 @@
-/*
- * 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.io.File;
-import java.io.FileInputStream;
-import java.io.FilenameFilter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.drools.reteoo.test.dsl.NodeTestCase;
-import org.junit.runner.RunWith;
-
-/**
- * A test case suite to manage and run all node test cases
- *
- * @author etirelli
- */
- at RunWith(JUnitNodeTestRunner.class)
-public class NodeTestsSuite
- implements
- NodeTestCasesSource {
-
- /* (non-Javadoc)
- * @see org.drools.reteoo.test.NodeTestCasesSource#getTestCases()
- */
- public List<NodeTestCase> getTestCases() throws Exception {
- List<NodeTestCase> result = new ArrayList<NodeTestCase>();
- File base = new File( this.getClass().getResource( "." ).toURI() );
- for ( File file : base.listFiles( new FilenameFilter() {
- @Override
- public boolean accept(File arg0,
- String arg1) {
- return arg1.endsWith( ".nodeTestCase" );
- }
- } ) ) {
- InputStream is = new FileInputStream( file );
- NodeTestCase tcase = ReteDslTestEngine.compile( is );
- if ( tcase.hasErrors() ) {
- throw new IllegalArgumentException( "Error parsing and loading testcase: " + file.getAbsolutePath() + "\n" + tcase.getErrors().toString() );
- }
- result.add( tcase );
- is.close();
- }
-
- return result;
- }
-
-}
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-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngine.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -49,12 +49,11 @@
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.LeftTupleSourceStep;
-import org.drools.reteoo.test.dsl.NodeTest;
+import org.drools.reteoo.test.dsl.NodeTestDef;
import org.drools.reteoo.test.dsl.NodeTestCase;
import org.drools.reteoo.test.dsl.NodeTestCaseResult;
import org.drools.reteoo.test.dsl.NotNodeStep;
@@ -114,8 +113,6 @@
new FactsStep( this.reteTesterHelper ) );
this.steps.put( "With",
new WithStep( this.reteTesterHelper ) );
- this.steps.put( "ForallNodeStep",
- new ForallNodeStep( this.reteTesterHelper ) );
this.steps.put( LEFT_TUPLE_SINK_STEP,
new LeftTupleSinkStep( this.reteTesterHelper ) );
this.steps.put( LEFT_TUPLE_SOURCE_STEP,
@@ -133,7 +130,7 @@
}
this.reteTesterHelper.addImports( testCase.getImports() );
NodeTestCaseResult result = new NodeTestCaseResult( testCase );
- for ( NodeTest test : testCase.getTests() ) {
+ for ( NodeTestDef test : testCase.getTests() ) {
notifier.fireTestStarted( test.getDescription() );
NodeTestResult testResult = run( testCase,
test );
@@ -152,7 +149,7 @@
}
private NodeTestResult run(NodeTestCase testCase,
- NodeTest test) {
+ NodeTestDef test) {
Map<String, Object> context = createContext( testCase );
NodeTestResult result = new NodeTestResult( test,
Result.NOT_EXECUTED,
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-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ReteDslTestEngineTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -29,7 +29,7 @@
import org.drools.reteoo.ReteooWorkingMemory;
import org.drools.reteoo.RuleTerminalNode;
import org.drools.reteoo.test.dsl.DslStep;
-import org.drools.reteoo.test.dsl.NodeTest;
+import org.drools.reteoo.test.dsl.NodeTestDef;
import org.drools.reteoo.test.dsl.NodeTestCase;
import org.drools.reteoo.test.dsl.NodeTestCaseResult;
import org.drools.reteoo.test.dsl.NodeTestCaseResult.NodeTestResult;
@@ -57,11 +57,11 @@
assertEquals( 0,
test.getTeardDown().size() );
- List<NodeTest> tests = test.getTests();
+ List<NodeTestDef> tests = test.getTests();
assertEquals( 2,
tests.size() );
- NodeTest test1 = tests.get( 0 );
+ NodeTestDef test1 = tests.get( 0 );
assertEquals( "test 1",
test1.getName() );
assertEquals( 19,
Deleted: 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 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/ForallNodeStep.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -1,99 +0,0 @@
-/*
- * 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
Deleted: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTest.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTest.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -1,65 +0,0 @@
-package org.drools.reteoo.test.dsl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.runner.Description;
-
-
-/**
- * A class to describe a single Node test
- *
- * @author etirelli
- */
-public class NodeTest {
-
- private String name;
- private int line;
- private List<DslStep> steps;
- private Description description;
-
- public NodeTest() {
- this( "", -1 );
- }
-
- public NodeTest(String name,
- int line) {
- super();
- this.name = name;
- this.line = line;
- this.steps = new ArrayList<DslStep>();
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getLine() {
- return line;
- }
-
- public void setLine(int line) {
- this.line = line;
- }
-
- public List<DslStep> getSteps() {
- return steps;
- }
-
- public void addStep(DslStep step) {
- this.steps.add( step );
- }
-
- public Description getDescription() {
- return description;
- }
-
- public void setDescription(Description description) {
- this.description = description;
- }
-
-}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCase.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCase.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCase.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -33,7 +33,7 @@
private List<String> imports;
private List<DslStep> setup;
private List<DslStep> teardDown;
- private List<NodeTest> tests;
+ private List<NodeTestDef> tests;
private List<String> errors;
private Description description;
@@ -46,7 +46,7 @@
this.imports = new ArrayList<String>();
this.setup = new ArrayList<DslStep>();
this.teardDown = new ArrayList<DslStep>();
- this.tests = new ArrayList<NodeTest>();
+ this.tests = new ArrayList<NodeTestDef>();
}
public String getName() {
@@ -73,10 +73,10 @@
public void addTearDownStep(DslStep step) {
this.teardDown.add( step );
}
- public List<NodeTest> getTests() {
+ public List<NodeTestDef> getTests() {
return tests;
}
- public void addTest(NodeTest test) {
+ public void addTest(NodeTestDef test) {
this.tests.add( test );
}
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCaseResult.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCaseResult.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestCaseResult.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -105,12 +105,12 @@
}
public static class NodeTestResult {
- public NodeTest test;
+ public NodeTestDef test;
public Result result;
public Map<String, Object> context;
public List<String> errorMsgs;
- public NodeTestResult(NodeTest test,
+ public NodeTestResult(NodeTestDef test,
Result result,
Map<String, Object> context,
List<String> errorMsgs) {
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestDef.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestDef.java (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestDef.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -0,0 +1,65 @@
+package org.drools.reteoo.test.dsl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.runner.Description;
+
+
+/**
+ * A class to describe a single Node test
+ *
+ * @author etirelli
+ */
+public class NodeTestDef {
+
+ private String name;
+ private int line;
+ private List<DslStep> steps;
+ private Description description;
+
+ public NodeTestDef() {
+ this( "", -1 );
+ }
+
+ public NodeTestDef(String name,
+ int line) {
+ super();
+ this.name = name;
+ this.line = line;
+ this.steps = new ArrayList<DslStep>();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getLine() {
+ return line;
+ }
+
+ public void setLine(int line) {
+ this.line = line;
+ }
+
+ public List<DslStep> getSteps() {
+ return steps;
+ }
+
+ public void addStep(DslStep step) {
+ this.steps.add( step );
+ }
+
+ public Description getDescription() {
+ return description;
+ }
+
+ public void setDescription(Description description) {
+ this.description = description;
+ }
+
+}
Property changes on: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/dsl/NodeTestDef.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/parser/NodeTestDSLFactory.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/parser/NodeTestDSLFactory.java 2010-02-05 20:55:55 UTC (rev 31463)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/parser/NodeTestDSLFactory.java 2010-02-05 23:45:02 UTC (rev 31464)
@@ -20,7 +20,7 @@
import org.antlr.runtime.tree.CommonTree;
import org.drools.reteoo.test.dsl.DslStep;
-import org.drools.reteoo.test.dsl.NodeTest;
+import org.drools.reteoo.test.dsl.NodeTestDef;
import org.drools.reteoo.test.dsl.NodeTestCase;
/**
@@ -35,7 +35,7 @@
}
private NodeTestCase testCase;
- private NodeTest test;
+ private NodeTestDef test;
private DslStep step;
private Context current;
@@ -54,7 +54,7 @@
public void createTest( CommonTree testToken, CommonTree name ) {
current = Context.TEST;
- test = new NodeTest( cleanString( name.getText() ), testToken.getLine() );
+ test = new NodeTestDef( cleanString( name.getText() ), testToken.getLine() );
testCase.addTest( test );
}
More information about the jboss-svn-commits
mailing list