예제 #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);
 }
예제 #2
0
 @Test(expected = TransformException.class)
 public void restoreBadQuery() throws RuleBaseException, TransformException {
   setModNearestAncestorImplementing(
       NodeTarget.class,
       new NodeTarget() {
         public ItemList targets() throws TransformException {
           return content.query().all("/id('c1')");
         }
       });
   setModScope(content.query().single("/id('c1')").node().query());
   SortByValueBlock block = define("<sort by='ascending'>*</sort>");
   SortByValueBlock.SortByValueSeg seg = (SortByValueBlock.SortByValueSeg) block.createSeg(mod);
   seg.restore();
 }
예제 #3
0
 private void runVerifyScenario(String proxyid, String modData)
     throws TransformException, RuleBaseException {
   Node um1 = content.query().single("/id('um1')").node();
   Node m1 = content.query().single("/id('m1')").node();
   setModNearestAncestorImplementing(
       NodeTarget.class,
       new NodeTarget() {
         public ItemList targets() throws TransformException {
           return content.query().all("/id('um1')");
         }
       });
   setModData(modData);
   setModReferences(content.query().single("/id($_1)", proxyid).node());
   setModScope(um1.query().let("$source", m1));
   SortByProxyBlock block = define("<sort as='corresponding'>$source</sort>");
   SortByProxyBlock.SortByProxySeg seg = (SortByProxyBlock.SortByProxySeg) block.createSeg(mod);
   seg.proxies = new ArrayList<Pair<String, Node>>();
   seg.proxies.add(Pair.of("um1", mod.references().get(0)));
   seg.verify();
 }
예제 #4
0
 @Test
 public void restore() throws RuleBaseException, TransformException {
   setModNearestAncestorImplementing(
       NodeTarget.class,
       new NodeTarget() {
         public ItemList targets() throws TransformException {
           return content.query().all("/id('um1 um2')");
         }
       });
   setModData("(<sort-proxy position='1'/>, <sort-proxy position='2'/>)");
   setModReferences(
       content.query().single("/id('m1')").node(), content.query().single("/id('m2')").node());
   SortByProxyBlock block = define("<sort as='corresponding'>$source</sort>");
   SortByProxyBlock.SortByProxySeg seg = (SortByProxyBlock.SortByProxySeg) block.createSeg(mod);
   seg.restore();
   assertEquals(
       Arrays.asList(
           new Pair[] {
             Pair.of("um1", content.query().single("/id('m1')").node()),
             Pair.of("um2", content.query().single("/id('m2')").node())
           }),
       seg.proxies);
 }
예제 #5
0
 @Test
 public void restore() throws RuleBaseException, TransformException {
   setModNearestAncestorImplementing(
       NodeTarget.class,
       new NodeTarget() {
         public ItemList targets() throws TransformException {
           return content.query().all("/id('m1 m2')");
         }
       });
   setModScope(
       content.query().single("/id('m1')").node().query(),
       content.query().single("/id('m2')").node().query());
   SortByValueBlock block = define("<sort by='ascending'>@name</sort>");
   SortByValueBlock.SortByValueSeg seg = (SortByValueBlock.SortByValueSeg) block.createSeg(mod);
   seg.restore();
   assertEquals(
       Arrays.asList(
           new Pair[] {
             Pair.of("m1", content.query().single("/id('m1')/@name").toAtomicItem()),
             Pair.of("m2", content.query().single("/id('m2')/@name").toAtomicItem())
           }),
       seg.values);
 }