}
@Test
@Ignore
public void testHierarchy() {
final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) this.ruleBase.newStatefulSession();
final Rete rete = ruleBase.getRete();
final IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
// Attach a List ObjectTypeNode
final ObjectTypeNode listOtn = new ObjectTypeNode(idGenerator.getNextId(),
this.entryPoint,
new ClassObjectType(List.class),
buildContext);
listOtn.attach(buildContext);
// Will automatically create an ArrayList ObjectTypeNode
FactHandle handle = workingMemory.insert(new ArrayList());
// Check we have three ObjectTypeNodes, List, ArrayList and InitialFactImpl
assertEquals(3,
rete.getObjectTypeNodes().size());
// double check that the List reference is the same as the one we created, i.e. engine should try and recreate it
assertSame(listOtn,
rete.getObjectTypeNodes(EntryPointId.DEFAULT).get(new ClassObjectType(List.class)));
// ArrayConf should match two ObjectTypenodes for List and ArrayList
ClassObjectTypeConf arrayConf = (ClassObjectTypeConf) workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf(this.entryPoint.getEntryPoint(), new ArrayList());
final ObjectTypeNode arrayOtn = arrayConf.getConcreteObjectTypeNode();
assertEquals(2,
arrayConf.getObjectTypeNodes().length);
// Check it contains List and ArrayList
List nodes = Arrays.asList(arrayConf.getObjectTypeNodes());
assertEquals(2,
nodes.size());
assertTrue(nodes.contains(arrayOtn));
assertTrue(nodes.contains(listOtn));
// Nodes are there, retract the fact so we can check both nodes are populated
workingMemory.retract(handle);
// Add MockSinks so we can track assertions
final MockObjectSink listSink = new MockObjectSink();
listOtn.addObjectSink(listSink);
final MockObjectSink arraySink = new MockObjectSink();
listOtn.addObjectSink(arraySink);
workingMemory.insert(new ArrayList());
assertEquals(1,
listSink.getAsserted().size());
assertEquals(1,
arraySink.getAsserted().size());