Example #1
0
 @Test
 public void restore() throws RuleBaseException, TransformException {
   Node comp1 = content.query().single("/id('comp1')").node();
   Node comp2 = content.query().single("/id('comp2')").node();
   Node cname = content.query().single("/id('cname')").node();
   setModNearestAncestorImplementing(
       NodeTarget.class,
       new NodeTarget() {
         public ItemList targets() throws TransformException {
           return content.query().all("/id('comp1 comp2')");
         }
       });
   setModData("(<sort-siblings run-length='2'/>, <sort-siblings run-length='1'/>)");
   setModReferences(cname, comp2, cname);
   SortBySiblingBlock block = define("<sort before='sibling'>uml:name</sort>");
   SortBySiblingBlock.SortBySiblingSeg seg =
       (SortBySiblingBlock.SortBySiblingSeg) block.createSeg(mod);
   seg.restore();
   assertEquals(
       Arrays.asList(
           new Pair[] {
             Pair.of(comp1, Arrays.asList(cname, comp2)), Pair.of(comp2, Arrays.asList(cname))
           }),
       seg.siblingsByTarget);
 }