Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 @Test(expected = TransformException.class)
 public void verifyBad() throws RuleBaseException, TransformException {
   SortByValueBlock block = define("<sort by='ascending'>@name</sort>");
   SortByValueBlock.SortByValueSeg seg = (SortByValueBlock.SortByValueSeg) block.createSeg(mod);
   setModData(
       "(<sort-value refid='m1'>start</sort-value>, <sort-value refid='m2'>foo</sort-value>)");
   seg.values = new ArrayList<Pair<String, Item>>();
   seg.values.add(Pair.of("m1", content.query().single("/id('m1')/@name").toAtomicItem()));
   seg.values.add(Pair.of("m2", content.query().single("/id('m2')/@name").toAtomicItem()));
   seg.verify();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
 }