Example #1
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();
 }
Example #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();
 }
Example #3
0
 @Test
 public void sortDescending() throws RuleBaseException {
   SortByValueBlock block = define("<sort by='descending'>@name</sort>");
   SortByValueBlock.SortByValueSeg seg1 = (SortByValueBlock.SortByValueSeg) block.createSeg(mod);
   SortByValueBlock.SortByValueSeg seg2 = (SortByValueBlock.SortByValueSeg) block.createSeg(mod);
   seg1.values = new ArrayList<Pair<String, Item>>();
   seg1.values.add(Pair.of("m1", content.query().single("/id('m1')/@name").toAtomicItem()));
   seg2.values = new ArrayList<Pair<String, Item>>();
   seg2.values.add(Pair.of("m2", content.query().single("/id('m2')/@name").toAtomicItem()));
   final OrderGraph graph = mockery.mock(OrderGraph.class);
   mockery.checking(
       new Expectations() {
         {
           one(graph).order("m1", "m2", 0);
         }
       });
   block.sort(Arrays.asList(seg1, seg2), graph);
 }
Example #4
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);
 }