Program: 75919
Project: 75919
Buggy source:
/** 
 * Test grand total
 * @throws Exception
 */
public void testAggrSort2Cache() throws Exception {
  this.createCube();
  ICubeQueryDefinition cqd=new CubeQueryDefinition(cubeName);
  IEdgeDefinition columnEdge=cqd.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IEdgeDefinition rowEdge=cqd.createEdge(ICubeQueryDefinition.ROW_EDGE);
  IDimensionDefinition dim1=columnEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier1=dim1.createHierarchy("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  ILevelDefinition level12=hier1.createLevel("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  IDimensionDefinition dim2=rowEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier2=dim2.createHierarchy("String_Node_Str");
  ILevelDefinition level21=hier2.createLevel("String_Node_Str");
  createSortTestBindings(cqd);
  CubeSortDefinition sorter1=new CubeSortDefinition();
  sorter1.setExpression("String_Node_Str");
  sorter1.setAxisQualifierLevel(null);
  sorter1.setAxisQualifierValue(null);
  sorter1.setTargetLevel(level21);
  sorter1.setSortDirection(ISortDefinition.SORT_DESC);
  CubeSortDefinition sorter2=new CubeSortDefinition();
  sorter2.setExpression("String_Node_Str");
  sorter2.setAxisQualifierLevel(new ILevelDefinition[]{level21});
  sorter2.setAxisQualifierValue(new Object[]{"String_Node_Str"});
  sorter2.setTargetLevel(level12);
  sorter2.setSortDirection(ISortDefinition.SORT_DESC);
  cqd.addSort(sorter1);
  cqd.addSort(sorter2);
  DataEngine engine=DataEngine.newDataEngine(DataEngineContext.newInstance(DataEngineContext.DIRECT_PRESENTATION,null,null,null));
  cqd.setCacheQueryResults(true);
  IPreparedCubeQuery pcq=engine.prepare(cqd,null);
  ICubeQueryResults queryResults=pcq.execute(null);
  CubeCursor cursor=queryResults.getCubeCursor();
  List columnEdgeBindingNames=new ArrayList();
  columnEdgeBindingNames.add("String_Node_Str");
  columnEdgeBindingNames.add("String_Node_Str");
  columnEdgeBindingNames.add("String_Node_Str");
  cqd.setQueryResultsID(queryResults.getID());
  pcq=engine.prepare(cqd,null);
  queryResults=pcq.execute(null);
  cursor=queryResults.getCubeCursor();
  printCube(cursor,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"},"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Test grand total
 * @throws Exception
 */
public void testAggrSort2Cache() throws Exception {
  ICubeQueryDefinition cqd=new CubeQueryDefinition(cubeName);
  IEdgeDefinition columnEdge=cqd.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IEdgeDefinition rowEdge=cqd.createEdge(ICubeQueryDefinition.ROW_EDGE);
  IDimensionDefinition dim1=columnEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier1=dim1.createHierarchy("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  ILevelDefinition level12=hier1.createLevel("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  IDimensionDefinition dim2=rowEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier2=dim2.createHierarchy("String_Node_Str");
  ILevelDefinition level21=hier2.createLevel("String_Node_Str");
  createSortTestBindings(cqd);
  CubeSortDefinition sorter1=new CubeSortDefinition();
  sorter1.setExpression("String_Node_Str");
  sorter1.setAxisQualifierLevel(null);
  sorter1.setAxisQualifierValue(null);
  sorter1.setTargetLevel(level21);
  sorter1.setSortDirection(ISortDefinition.SORT_DESC);
  CubeSortDefinition sorter2=new CubeSortDefinition();
  sorter2.setExpression("String_Node_Str");
  sorter2.setAxisQualifierLevel(new ILevelDefinition[]{level21});
  sorter2.setAxisQualifierValue(new Object[]{"String_Node_Str"});
  sorter2.setTargetLevel(level12);
  sorter2.setSortDirection(ISortDefinition.SORT_DESC);
  cqd.addSort(sorter1);
  cqd.addSort(sorter2);
  DataEngine engine=DataEngine.newDataEngine(DataEngineContext.newInstance(DataEngineContext.DIRECT_PRESENTATION,null,null,null));
  this.createCube(engine);
  cqd.setCacheQueryResults(true);
  IPreparedCubeQuery pcq=engine.prepare(cqd,null);
  ICubeQueryResults queryResults=pcq.execute(null);
  CubeCursor cursor=queryResults.getCubeCursor();
  List columnEdgeBindingNames=new ArrayList();
  columnEdgeBindingNames.add("String_Node_Str");
  columnEdgeBindingNames.add("String_Node_Str");
  columnEdgeBindingNames.add("String_Node_Str");
  cqd.setQueryResultsID(queryResults.getID());
  pcq=engine.prepare(cqd,null);
  queryResults=pcq.execute(null);
  cursor=queryResults.getCubeCursor();
  printCube(cursor,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"},"String_Node_Str","String_Node_Str");
}