40 );
p3.setStatus( "europe" );
final FactHandle c3FactHandle = workingMemory.insert( p3 );
workingMemory.fireAllRules();
QueryResults queryResults = workingMemory.getQueryResults( "2 persons with the same status" );
assertEquals( 2,
queryResults.size() );
// europe=[ 1, 2 ], america=[ 3 ]
p3.setStatus( "america" );
workingMemory.update( c3FactHandle,
p3 );
workingMemory.fireAllRules();
queryResults = workingMemory.getQueryResults( "2 persons with the same status" );
assertEquals( 1,
queryResults.size() );
// europe=[ 1 ], america=[ 2, 3 ]
p2.setStatus( "america" );
workingMemory.update( c2FactHandle,
p2 );
workingMemory.fireAllRules();
queryResults = workingMemory.getQueryResults( "2 persons with the same status" );
assertEquals( 1,
queryResults.size() );
// europe=[ ], america=[ 1, 2, 3 ]
p1.setStatus( "america" );
workingMemory.update( c1FactHandle,
p1 );
workingMemory.fireAllRules();
queryResults = workingMemory.getQueryResults( "2 persons with the same status" );
assertEquals( 2,
queryResults.size() );
// europe=[ 2 ], america=[ 1, 3 ]
p2.setStatus( "europe" );
workingMemory.update( c2FactHandle,
p2 );
workingMemory.fireAllRules();
queryResults = workingMemory.getQueryResults( "2 persons with the same status" );
assertEquals( 1,
queryResults.size() );
// europe=[ 1, 2 ], america=[ 3 ]
p1.setStatus( "europe" );
workingMemory.update( c1FactHandle,
p1 );
workingMemory.fireAllRules();
queryResults = workingMemory.getQueryResults( "2 persons with the same status" );
assertEquals( 1,
queryResults.size() );
// europe=[ 1, 2, 3 ], america=[ ]
p3.setStatus( "europe" );
workingMemory.update( c3FactHandle,
p3 );
workingMemory.fireAllRules();
queryResults = workingMemory.getQueryResults( "2 persons with the same status" );
assertEquals( 2,
queryResults.size() );
}