示例#1
0
 @SuppressWarnings("unchecked")
 @Test
 public void sortAfter() throws RuleBaseException {
   final Node comp1 = content.query().single("/id('comp1')").node();
   final Node comp2 = content.query().single("/id('comp2')").node();
   final Node cname = content.query().single("/id('cname')").node();
   SortBySiblingBlock block = define("<sort after='sibling'>uml:name</sort>");
   SortBySiblingBlock.SortBySiblingSeg seg1 =
       (SortBySiblingBlock.SortBySiblingSeg) block.createSeg(mod);
   SortBySiblingBlock.SortBySiblingSeg seg2 =
       (SortBySiblingBlock.SortBySiblingSeg) block.createSeg(mod);
   seg1.siblingsByTarget =
       Arrays.<Pair<Node, List<Node>>>asList(
           new Pair[] {
             Pair.of(comp1, Arrays.asList(cname, comp2)), Pair.of(comp2, Arrays.asList(cname))
           });
   seg2.siblingsByTarget =
       Arrays.<Pair<Node, List<Node>>>asList(new Pair[] {Pair.of(cname, Arrays.asList(comp2))});
   final OrderGraph graph = mockery.mock(OrderGraph.class);
   mockery.checking(
       new Expectations() {
         {
           one(graph).order(cname, comp1, 0);
           one(graph).order(comp2, comp1, 0);
           one(graph).order(cname, comp2, 0);
           one(graph).order(comp2, cname, 0);
         }
       });
   block.sort(Arrays.asList(seg1, seg2), graph);
 }
示例#2
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);
 }
示例#3
0
 @SuppressWarnings("unchecked")
 @Test(expected = TransformException.class)
 public void verifyNotSibling() throws RuleBaseException, TransformException {
   Node uc1 = content.query().single("/id('uc1')").node();
   Node comp1 = content.query().single("/id('comp1')").node();
   Node um1 = content.query().single("/id('um1')").node();
   setModScope(uc1.query());
   SortBySiblingBlock block = define("<sort before='sibling'>.//uml:method</sort>");
   SortBySiblingBlock.SortBySiblingSeg seg =
       (SortBySiblingBlock.SortBySiblingSeg) block.createSeg(mod);
   seg.siblingsByTarget =
       Arrays.<Pair<Node, List<Node>>>asList(new Pair[] {Pair.of(comp1, Arrays.asList(um1))});
   seg.verify();
 }
示例#4
0
 @SuppressWarnings("unchecked")
 @Test
 public void verify() throws RuleBaseException, TransformException {
   Node uc1 = content.query().single("/id('uc1')").node();
   Node comp1 = content.query().single("/id('comp1')").node();
   Node comp2 = content.query().single("/id('comp2')").node();
   Node cname = content.query().single("/id('cname')").node();
   setModScope(uc1.query());
   SortBySiblingBlock block = define("<sort before='sibling'>uml:name</sort>");
   SortBySiblingBlock.SortBySiblingSeg seg =
       (SortBySiblingBlock.SortBySiblingSeg) block.createSeg(mod);
   seg.siblingsByTarget =
       Arrays.<Pair<Node, List<Node>>>asList(
           new Pair[] {
             Pair.of(comp1, Arrays.asList(cname)), Pair.of(comp2, Arrays.asList(cname))
           });
   seg.verify();
 }