Program: 75744
Project: 75744
Buggy source:
private void testFactTableSaveAndLoad5(CubeMaterializer cubeMaterializer) 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]=CubeElementFactory.createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=CubeElementFactory.createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=CubeElementFactory.createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  IHierarchy hierarchy=cubeMaterializer.createHierarchy("String_Node_Str","String_Node_Str",iterator,levelDefs);
  dimensions[0]=(Dimension)cubeMaterializer.createDimension("String_Node_Str",hierarchy);
  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]=CubeElementFactory.createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  hierarchy=cubeMaterializer.createHierarchy("String_Node_Str","String_Node_Str",iterator,levelDefs);
  dimensions[1]=(Dimension)cubeMaterializer.createDimension("String_Node_Str",hierarchy);
  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);
  hierarchy=cubeMaterializer.createHierarchy("String_Node_Str","String_Node_Str",iterator,levelDefs);
  dimensions[2]=(Dimension)cubeMaterializer.createDimension("String_Node_Str",hierarchy);
  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";
  cubeMaterializer.createCube("String_Node_Str",dimensions,factTable2,measureColumnName,new StopSign());
  CubeQueryExecutorHelper cubeQueryExcutorHelper=new CubeQueryExecutorHelper(CubeQueryExecutorHelper.loadCube("String_Node_Str",cubeMaterializer.getDocumentManager(),new StopSign()));
  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 testFactTableSaveAndLoad5(CubeMaterializer cubeMaterializer) 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 CubeElementFactory().createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=new CubeElementFactory().createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=new CubeElementFactory().createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  IHierarchy hierarchy=cubeMaterializer.createHierarchy("String_Node_Str","String_Node_Str",iterator,levelDefs);
  dimensions[0]=(Dimension)cubeMaterializer.createDimension("String_Node_Str",hierarchy);
  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]=CubeElementFactory.createLevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  hierarchy=cubeMaterializer.createHierarchy("String_Node_Str","String_Node_Str",iterator,levelDefs);
  dimensions[1]=(Dimension)cubeMaterializer.createDimension("String_Node_Str",hierarchy);
  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);
  hierarchy=cubeMaterializer.createHierarchy("String_Node_Str","String_Node_Str",iterator,levelDefs);
  dimensions[2]=(Dimension)cubeMaterializer.createDimension("String_Node_Str",hierarchy);
  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";
  cubeMaterializer.createCube("String_Node_Str",dimensions,factTable2,measureColumnName,new StopSign());
  CubeQueryExecutorHelper cubeQueryExcutorHelper=new CubeQueryExecutorHelper(CubeQueryExecutorHelper.loadCube("String_Node_Str",cubeMaterializer.getDocumentManager(),new StopSign()));
  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));
}