}
@Test
public void testMultipleLogicalRelationships() throws FactException {
final Rule rule1 = new Rule( "test-rule1" );
IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
final Rete rete = ruleBase.getRete();
// Create a RuleBase with a single ObjectTypeNode we attach a
// MockObjectSink so we can detect assertions and retractions
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
this.entryPoint,
new ClassObjectType( String.class ),
buildContext );
objectTypeNode.attach();
MockRightTupleSink sink = new MockRightTupleSink();
final RuleTerminalNode node = new RuleTerminalNode( idGenerator.getNextId(),
new MockTupleSource( idGenerator.getNextId() ),
rule1,
rule1.getLhs(),
0,
buildContext );
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
final Agenda agenda = workingMemory.getAgenda();
final Consequence consequence = new Consequence() {
private static final long serialVersionUID = 510l;
public void evaluate(KnowledgeHelper knowledgeHelper,
WorkingMemory workingMemory) {
// do nothing
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
}
public void writeExternal(ObjectOutput out) throws IOException {
}
public String getName() {
return "default";
}
};
// Create first justifier
rule1.setConsequence( consequence );
final DefaultFactHandle handle1 = new DefaultFactHandle( 1,
"cheese" );
final LeftTupleImpl tuple1 = new LeftTupleImpl( handle1,
null,
true );
final PropagationContext context1 = new PropagationContextImpl( 0,
PropagationContext.ASSERTION,
null,
null,
null );
// get the activation onto the agenda
node.assertLeftTuple( tuple1,
context1,
workingMemory );
// Create the second justifier
final Rule rule2 = new Rule( "test-rule2" );
final RuleTerminalNode node2 = new RuleTerminalNode( idGenerator.getNextId(),
new MockTupleSource( idGenerator.getNextId() ),
rule2,
rule2.getLhs(),
0,
buildContext );
rule2.setConsequence( consequence );