LeftTuple firstTuple = new LeftTupleImpl( first.get( 0 ),
null,
false);
for ( int i = 1; i < first.size(); i++ ) {
firstTuple = new LeftTupleImpl( firstTuple,
new RightTuple( first.get( i )),
null,
false );
}
List<LeftTuple> leftTuples = new ArrayList<LeftTuple>();
for ( LeftTuple leftTuple = getFirst(memory.getLeftTupleMemory(), firstTuple); leftTuple != null; leftTuple = (LeftTuple) leftTuple.getNext() ) {
leftTuples.add( leftTuple );
}
if ( lrUnlinkingEnabled ) {
// When L&R Unlinking is active, we need to sort the
// tuples here,
// because we might have asserted things in the wrong
// order,
// since linking a node's side means populating its
// memory
// from the OTN which stores things in a hash-set, so
// insertion order is not kept.
Collections.sort( leftTuples,
new LeftTupleComparator() );
}
List<List<InternalFactHandle>> actualLeftTuples = getHandlesList( leftTuples );
if ( !expectedLeftTuples.equals( actualLeftTuples ) ) {
throw new AssertionError( "line " + step.getLine() + ": left Memory expected " + expectedLeftTuples + " actually " + actualLeftTuples );
}
} else if ( cmd[0].equals( "rightMemory" ) ) {
String args = cmd[1];
String listString = args.replaceAll( "h(\\d+)",
"h[$1]" );
Map<String, Object> vars = new HashMap<String, Object>();
vars.put( "h",
handles );
List< ? > expectedFactHandles = (List< ? >) MVEL.eval( listString,
vars );
RightTupleMemory rightMemory = memory.getRightTupleMemory();
if ( expectedFactHandles.isEmpty() && rightMemory.size() != 0 ) {
throw new AssertionError( "line " + step.getLine() + ": right Memory expected [] actually " + print( rightMemory ));
} else if ( expectedFactHandles.isEmpty() && rightMemory.size() == 0 ) {
continue;
}
RightTuple first = new RightTuple( (InternalFactHandle) expectedFactHandles.get( 0 ) );
List<RightTuple> actualRightTuples = new ArrayList<RightTuple>();
for ( RightTuple rightTuple = getFirst(memory.getRightTupleMemory(), first); rightTuple != null; rightTuple = (RightTuple) rightTuple.getNext() ) {
actualRightTuples.add( rightTuple );
}