use of org.whole.lang.misc.model.Misc in project whole by wholeplatform.
the class IteratorFactoryTest method testAncestorOrSelfIteratorRemoveSet.
@Test
public void testAncestorOrSelfIteratorRemoveSet() {
Grammar g = new TestXmlGrammar().create();
MiscEntityFactory mef = MiscEntityFactory.instance(RegistryConfigurations.RESOLVER);
Any any = CommonsEntityAdapterFactory.create(MiscEntityDescriptorEnum.Any, g);
Misc innerMisc = mef.createMisc(any);
any = CommonsEntityAdapterFactory.create(MiscEntityDescriptorEnum.Any, innerMisc);
Misc outerMisc = mef.createMisc(any);
Rule r = Matcher.find(GrammarsEntityDescriptorEnum.As, outerMisc, false);
IEntityIterator<IEntity> i = IteratorFactory.ancestorOrSelfIterator();
i.reset(r);
IEntity next = null;
while (i.hasNext()) {
next = i.next();
if (Matcher.match(MiscEntityDescriptorEnum.Misc, next))
break;
}
assertSame(innerMisc, next);
i.set(EntityUtils.clone(any));
assertEquals(1, outerMisc.wSize());
Rule r2 = Matcher.find(GrammarsEntityDescriptorEnum.As, outerMisc, false);
assertTrue(Matcher.match(r, r2));
assertNotSame(r, r2);
i.remove();
assertEquals(0, outerMisc.wSize());
i.reset(r2);
while (i.hasNext()) {
next = i.next();
if (i.hasNext())
i.remove();
}
assertFalse(EntityUtils.hasParent(next));
}
Aggregations