Program: 75693
Project: 75693
Buggy source:
private void testFactTableSaveAndLoad4(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[3];
  String[] levelNames=new String[3];
  levelNames[0]="String_Node_Str";
  levelNames[1]="String_Node_Str";
  levelNames[2]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L1Col);
  iterator.setLevelMember(1,FactTable2.L2Col);
  iterator.setLevelMember(2,FactTable2.L3Col);
  ILevelDefn[] levelDefs=new ILevelDefn[3];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[0]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[0].length(),FactTable2.L1Col.length);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(FactTable2.L1Col));
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[1]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[1].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[1].length(),3);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L3Col);
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[2]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[2].length(),12);
  FactTable2 factTable2=new FactTable2();
  String[] measureColumnName=new String[2];
  measureColumnName[0]="String_Node_Str";
  measureColumnName[1]="String_Node_Str";
  Cube cube=new Cube("String_Node_Str",documentManager);
  cube.create(dimensions,factTable2,measureColumnName,new StopSign());
  CubeQueryExecutorHelper cubeQueryExcutorHelper=new CubeQueryExecutorHelper(cube);
  ISelection[][] filter=new ISelection[1][1];
  filter[0][0]=SelectionFactory.createRangeSelection(new Object[]{new Integer(1)},new Object[]{new Integer(3)},true,false);
  cubeQueryExcutorHelper.addFilter(new LevelFilter(dimLevel21,filter[0]));
  AggregationDefinition[] aggregations=new AggregationDefinition[2];
  int[] sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  DimLevel[] levelsForFilter=new DimLevel[]{dimLevel21};
  AggregationFunctionDefinition[] funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",IBuildInAggregation.TOTAL_SUM_FUNC);
  aggregations[0]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  sortType=new int[2];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  sortType[1]=IDimensionSortDefn.SORT_ASC;
  levelsForFilter=new DimLevel[]{dimLevel31};
  aggregations[1]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  IAggregationResultSet[] resultSet=cubeQueryExcutorHelper.execute(aggregations,new StopSign());
  assertEquals(resultSet[0].length(),2);
  assertEquals(resultSet[0].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[0].getLevelIndex(dimLevel21),0);
  assertEquals(resultSet[0].getLevelKeyDataType(dimLevel21,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[0].seek(0);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(6));
  resultSet[0].seek(1);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[1].length(),8);
  assertEquals(resultSet[1].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[1].getLevelIndex(dimLevel31),0);
  assertEquals(resultSet[1].getLevelKeyDataType(dimLevel31,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[1].seek(0);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(0));
  resultSet[1].seek(1);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(1));
  resultSet[1].seek(2);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(3));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(2));
  resultSet[1].seek(3);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(4));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(3));
  resultSet[1].seek(4);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(5));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(4));
  resultSet[1].seek(5);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(6));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(5));
  resultSet[1].seek(6);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(7));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(6));
  resultSet[1].seek(7);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(8));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(7));
}

Fixed version (ground truth):
private void testFactTableSaveAndLoad4(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[3];
  String[] levelNames=new String[3];
  levelNames[0]="String_Node_Str";
  levelNames[1]="String_Node_Str";
  levelNames[2]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L1Col);
  iterator.setLevelMember(1,FactTable2.L2Col);
  iterator.setLevelMember(2,FactTable2.L3Col);
  ILevelDefn[] levelDefs=new ILevelDefn[3];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[0]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[0].length(),FactTable2.L1Col.length);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(FactTable2.L1Col));
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[1]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[1].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[1].length(),3);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L3Col);
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[2]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[2].length(),12);
  FactTable2 factTable2=new FactTable2();
  String[] measureColumnName=new String[2];
  measureColumnName[0]="String_Node_Str";
  measureColumnName[1]="String_Node_Str";
  Cube cube=new Cube("String_Node_Str",documentManager);
  cube.create(CubeUtility.getKeyColNames(dimensions),dimensions,factTable2,measureColumnName,new StopSign());
  CubeQueryExecutorHelper cubeQueryExcutorHelper=new CubeQueryExecutorHelper(cube);
  ISelection[][] filter=new ISelection[1][1];
  filter[0][0]=SelectionFactory.createRangeSelection(new Object[]{new Integer(1)},new Object[]{new Integer(3)},true,false);
  cubeQueryExcutorHelper.addFilter(new LevelFilter(dimLevel21,filter[0]));
  AggregationDefinition[] aggregations=new AggregationDefinition[2];
  int[] sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  DimLevel[] levelsForFilter=new DimLevel[]{dimLevel21};
  AggregationFunctionDefinition[] funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",IBuildInAggregation.TOTAL_SUM_FUNC);
  aggregations[0]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  sortType=new int[2];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  sortType[1]=IDimensionSortDefn.SORT_ASC;
  levelsForFilter=new DimLevel[]{dimLevel31};
  aggregations[1]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  IAggregationResultSet[] resultSet=cubeQueryExcutorHelper.execute(aggregations,new StopSign());
  assertEquals(resultSet[0].length(),2);
  assertEquals(resultSet[0].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[0].getLevelIndex(dimLevel21),0);
  assertEquals(resultSet[0].getLevelKeyDataType(dimLevel21,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[0].seek(0);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(6));
  resultSet[0].seek(1);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[1].length(),8);
  assertEquals(resultSet[1].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[1].getLevelIndex(dimLevel31),0);
  assertEquals(resultSet[1].getLevelKeyDataType(dimLevel31,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[1].seek(0);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(0));
  resultSet[1].seek(1);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(1));
  resultSet[1].seek(2);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(3));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(2));
  resultSet[1].seek(3);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(4));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(3));
  resultSet[1].seek(4);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(5));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(4));
  resultSet[1].seek(5);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(6));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(5));
  resultSet[1].seek(6);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(7));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(6));
  resultSet[1].seek(7);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(8));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(7));
}