### Question:
QueryCompilerPass2 extends AqlBaseListener { List<OrderAttribute> getOrderAttributes() { if (orderAttributes == null) return null; return new ArrayList<>(orderAttributes); }  @Override void exitObjectPath(AqlParser.ObjectPathContext objectPathContext); @Override void exitSelectExpr(AqlParser.SelectExprContext selectExprContext); @Override void exitTopExpr(AqlParser.TopExprContext context); @Override void exitOrderBySeq(AqlParser.OrderBySeqContext context); @Override void exitOffset(AqlParser.OffsetContext ctx); @Override void exitLimit(AqlParser.LimitContext ctx); @Override void exitFunction(AqlParser.FunctionContext functionContext); List<I_VariableDefinition> getVariables();  }### Answer:
@Test public void getOrderAttributes() { ParseTreeWalker walker = new ParseTreeWalker(); { QueryCompilerPass2 cut = new QueryCompilerPass2(); String aql = "select a/uid/value as uid, a/composer/name as author, a/context/start_time/value " + "from EHR e contains COMPOSITION a[openEHR-EHR-COMPOSITION.health_summary.v1] " + "order by a/context/start_time/value DESC"; ParseTree tree = QueryHelper.setupParseTree(aql); walker.walk(cut, tree); List<OrderAttribute> orderAttributes = cut.getOrderAttributes(); Assertions.assertThat(orderAttributes).size().isEqualTo(1); OrderAttribute orderAttribute = orderAttributes.get(0); assertThat(orderAttribute.getDirection()).isEqualTo(OrderAttribute.OrderDirection.DESC); I_VariableDefinition expected = I_VariableDefinitionHelper.build("context/start_time/value", null, "a", false, false, false); I_VariableDefinitionHelper.checkEqualWithoutFuncParameters(orderAttribute.getVariableDefinition(), expected); } { QueryCompilerPass2 cut = new QueryCompilerPass2(); String aql = "select a/uid/value as uid, a/composer/name as author, a/context/start_time/value as date_created " + "from EHR e contains COMPOSITION a[openEHR-EHR-COMPOSITION.health_summary.v1] " + "order by date_created ASC"; ParseTree tree = QueryHelper.setupParseTree(aql); walker.walk(cut, tree); List<OrderAttribute> orderAttributes = cut.getOrderAttributes(); Assertions.assertThat(orderAttributes).size().isEqualTo(1); OrderAttribute orderAttribute = orderAttributes.get(0); assertThat(orderAttribute.getDirection()).isEqualTo(OrderAttribute.OrderDirection.ASC); I_VariableDefinition expected = I_VariableDefinitionHelper.build(null, "date_created", null, false, false, false); I_VariableDefinitionHelper.checkEqualWithoutFuncParameters(orderAttribute.getVariableDefinition(), expected); } }