@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); }