コード例 #1
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test(expected = TransformException.class)
 public void resolveOrderBadQuery() throws RuleBaseException, TransformException {
   SortBlock block = define("<sort as='corresponding'>*</sort>");
   Node uc1 = content.query().single("/id('uc1')").node();
   setModBuilderCustomScope(uc1.query());
   block.resolveOrder(modBuilder, uc1);
 }
コード例 #2
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test
 public void totalOrder() throws RuleBaseException {
   SortBlock block = define("<sort by='ascending' priority='5'>@foo</sort>");
   final OrderGraph graph = mockery.mock(OrderGraph.class);
   mockery.checking(
       new Expectations() {
         {
           one(graph).order("x2", "x1", 5);
           one(graph).order("x2", "x3", 5);
           one(graph).order("x2", "x4", 5);
           one(graph).order("x1", "x4", 5);
           one(graph).order("x3", "x4", 5);
         }
       });
   List<Pair<String, Integer>> list = new ArrayList<Pair<String, Integer>>();
   list.add(Pair.of("x1", 23));
   list.add(Pair.of("x2", 18));
   list.add(Pair.of("x3", 23));
   list.add(Pair.of("x4", 35));
   Comparator<Pair<String, Integer>> comparator =
       new Comparator<Pair<String, Integer>>() {
         public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) {
           return o1.second.compareTo(o2.second);
         }
       };
   block.totalOrder(list, comparator, graph);
 }
コード例 #3
0
ファイル: Sort.java プロジェクト: young36832/dscribe
    @Test
    public void resolve() throws RuleBaseException, TransformException {
      final Node m1 = content.query().single("/id('m1')").node();
      final Node m2 = content.query().single("/id('m2')").node();
      final SortBlock mockBlock = mockery.mock(SortBlock.class);
      SortBlock block =
          new SortBlock(
              db.getFolder("/")
                  .documents()
                  .load(
                      Name.create("rule"),
                      Source.xml("<rule><sort by='ascending'>@foo</sort></rule>"))
                  .root()
                  .query()
                  .single("*")
                  .node()) {
            @Override
            void resolveOrder(Builder aModBuilder, Node node) throws TransformException {
              mockBlock.resolveOrder(aModBuilder, node);
            }

            @Override
            public Seg createSeg(Mod unused) {
              fail();
              return null;
            }
          };
      modBuilder = mockery.mock(Mod.Builder.class);
      mockery.checking(
          new Expectations() {
            {
              one(modBuilder).dependOn(m1.document());
              one(modBuilder).dependOn(m2.document());
              Sequence seq1 = mockery.sequence("pre-commit resolveOrder 1");
              Sequence seq2 = mockery.sequence("pre-commit resolveOrder 2");
              one(mockBlock).resolveOrder(modBuilder, m1);
              inSequence(seq1);
              one(mockBlock).resolveOrder(modBuilder, m2);
              inSequence(seq2);
              modBuilderPriors.add(seq1);
              modBuilderPriors.add(seq2);
            }
          });
      block.requiredVariables =
          Arrays.asList(new QName[] {new QName(null, "a", null), new QName(null, "b", null)});
      dependOnNearest(
          NodeTarget.class,
          false,
          new NodeTarget() {
            public ItemList targets() throws TransformException {
              return content.query().all("/id('m1 m2')");
            }
          });
      order("m1");
      order("m2");
      dependOnVariables(new QName(null, "a", null), new QName(null, "b", null));
      thenCommit();
      block.resolve(modBuilder);
    }
コード例 #4
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test(expected = TransformException.class)
 public void resolveOrderNotSibling() throws RuleBaseException, TransformException {
   SortBlock block = define("<sort before='sibling'>.//uml:operation</sort>");
   Node cname = content.query().single("/id('cname')").node();
   Node uc1 = content.query().single("/id('uc1')").node();
   setModBuilderCustomScope(uc1.query());
   block.resolveOrder(modBuilder, cname);
 }
コード例 #5
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test
 public void analyze() throws RuleBaseException, TransformException {
   SortBlock block = define("<sort as='corresponding'>$src</sort>");
   setModGlobalScope(content.query());
   Seg seg = block.createSeg(mod);
   seg.analyze();
   assertThat(block.requiredVariables, is(collection(new QName(null, "src", null))));
 }
コード例 #6
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test
 public void resolveOrder() throws RuleBaseException, TransformException {
   SortBlock block = define("<sort by='ascending'>@name</sort>");
   Node m1 = content.query().single("/id('m1')").node();
   setModBuilderCustomScope(m1.query());
   supplement();
   block.resolveOrder(modBuilder, m1);
   checkSupplement("<sort-value refid='m1'>start</sort-value>");
 }
コード例 #7
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test
 public void resolveOrderEmpty() throws RuleBaseException, TransformException {
   SortBlock block = define("<sort before='sibling'>()</sort>");
   Node cname = content.query().single("/id('cname')").node();
   Node uc1 = content.query().single("/id('uc1')").node();
   setModBuilderCustomScope(uc1.query());
   supplement();
   block.resolveOrder(modBuilder, cname);
   checkSupplement("<sort-siblings run-length='0'/>");
 }
コード例 #8
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test
 public void resolveOrder1() throws RuleBaseException, TransformException {
   SortBlock block = define("<sort after='sibling'>uml:name</sort>");
   Node comp1 = content.query().single("/id('comp1')").node();
   Node uc1 = content.query().single("/id('uc1')").node();
   setModBuilderCustomScope(uc1.query());
   reference(content.query().single("/id('cname')").node());
   supplement();
   block.resolveOrder(modBuilder, comp1);
   checkSupplement("<sort-siblings run-length='1'/>");
 }
コード例 #9
0
ファイル: Sort.java プロジェクト: young36832/dscribe
 @Test
 public void resolveOrder() throws RuleBaseException, TransformException {
   SortBlock block = define("<sort as='corresponding'>$source</sort>");
   Node um1 = content.query().single("/id('um1')").node();
   Node m1 = content.query().single("/id('m1')").node();
   setModBuilderCustomScope(um1.query().let("$source", m1));
   reference(m1);
   supplement();
   block.resolveOrder(modBuilder, um1);
   checkSupplement("<sort-proxy position='1'/>");
 }