예제 #1
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);
 }
예제 #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();
 }