Program: 75977
Project: 75977
Buggy source:
private void testCubeCreate2(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[2];
  String[] ColNames=new String[3];
  ColNames[0]="String_Node_Str";
  ColNames[1]="String_Node_Str";
  ColNames[2]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(ColNames);
  iterator.setLevelMember(0,TestFactTable.L1Col);
  iterator.setLevelMember(1,TestFactTable.L2Col);
  iterator.setLevelMember(2,TestFactTable.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(),TestFactTable.L1Col.length);
  ColNames=new String[1];
  ColNames[0]="String_Node_Str";
  iterator=new DimensionForTest(ColNames);
  iterator.setLevelMember(0,distinct(TestFactTable.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);
  TestFactTable factTable2=new TestFactTable();
  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[]{"String_Node_Str"},new Object[]{"String_Node_Str"},true,false);
  cubeQueryExcutorHelper.addFilter("String_Node_Str",filter[0]);
  AggregationDefinition[] aggregations=new AggregationDefinition[4];
  int[] sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  String[] levelNamesForFilter=new String[1];
  levelNamesForFilter[0]="String_Node_Str";
  AggregationFunctionDefinition[] funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[0]=new AggregationDefinition(levelNamesForFilter,sortType,funcitons);
  sortType=new int[2];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  sortType[1]=IDimensionSortDefn.SORT_ASC;
  levelNamesForFilter=new String[2];
  levelNamesForFilter[0]="String_Node_Str";
  levelNamesForFilter[1]="String_Node_Str";
  funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[1]=new AggregationDefinition(levelNamesForFilter,sortType,funcitons);
  sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  levelNamesForFilter=new String[1];
  levelNamesForFilter[0]="String_Node_Str";
  funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[2]=new AggregationDefinition(levelNamesForFilter,sortType,funcitons);
  sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  levelNamesForFilter=new String[1];
  levelNamesForFilter[0]="String_Node_Str";
  funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[3]=new AggregationDefinition(levelNamesForFilter,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("String_Node_Str"),0);
  assertEquals(resultSet[0].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  resultSet[0].seek(0);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[0].getAggregationValue(0),new Double(6));
  resultSet[0].seek(1);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[0].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[1].length(),4);
  assertEquals(resultSet[1].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[1].getLevelIndex("String_Node_Str"),-1);
  assertEquals(resultSet[1].getLevelIndex("String_Node_Str"),0);
  assertEquals(resultSet[1].getLevelIndex("String_Node_Str"),1);
  assertEquals(resultSet[1].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  assertEquals(resultSet[1].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[1].seek(0);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(1));
  resultSet[1].seek(1);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(5));
  resultSet[1].seek(2);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(9));
  resultSet[1].seek(3);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(13));
  assertEquals(resultSet[2].length(),2);
  assertEquals(resultSet[2].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[2].getLevelIndex("String_Node_Str"),0);
  assertEquals(resultSet[2].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  resultSet[2].seek(0);
  assertEquals(resultSet[2].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[2].getAggregationValue(0),new Double(6));
  resultSet[2].seek(1);
  assertEquals(resultSet[2].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[2].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[3].length(),2);
  assertEquals(resultSet[3].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[3].getLevelIndex("String_Node_Str"),0);
  assertEquals(resultSet[3].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  resultSet[3].seek(0);
  assertEquals(resultSet[3].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[3].getAggregationValue(0),new Double(6));
  resultSet[3].seek(1);
  assertEquals(resultSet[3].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[3].getAggregationValue(0),new Double(22));
}

Fixed version (ground truth):
private void testCubeCreate2(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[2];
  String[] ColNames=new String[3];
  ColNames[0]="String_Node_Str";
  ColNames[1]="String_Node_Str";
  ColNames[2]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(ColNames);
  iterator.setLevelMember(0,TestFactTable.L1Col);
  iterator.setLevelMember(1,TestFactTable.L2Col);
  iterator.setLevelMember(2,TestFactTable.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(),TestFactTable.L1Col.length);
  ColNames=new String[1];
  ColNames[0]="String_Node_Str";
  iterator=new DimensionForTest(ColNames);
  iterator.setLevelMember(0,distinct(TestFactTable.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);
  TestFactTable factTable2=new TestFactTable();
  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[]{"String_Node_Str"},new Object[]{"String_Node_Str"},true,false);
  cubeQueryExcutorHelper.addFilter("String_Node_Str",filter[0]);
  AggregationDefinition[] aggregations=new AggregationDefinition[4];
  int[] sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  String[] levelNamesForFilter=new String[1];
  levelNamesForFilter[0]="String_Node_Str";
  AggregationFunctionDefinition[] funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[0]=new AggregationDefinition(levelNamesForFilter,sortType,funcitons);
  sortType=new int[2];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  sortType[1]=IDimensionSortDefn.SORT_ASC;
  levelNamesForFilter=new String[2];
  levelNamesForFilter[0]="String_Node_Str";
  levelNamesForFilter[1]="String_Node_Str";
  funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[1]=new AggregationDefinition(levelNamesForFilter,sortType,funcitons);
  sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  levelNamesForFilter=new String[1];
  levelNamesForFilter[0]="String_Node_Str";
  funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[2]=new AggregationDefinition(levelNamesForFilter,sortType,funcitons);
  sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  levelNamesForFilter=new String[1];
  levelNamesForFilter[0]="String_Node_Str";
  funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",BuiltInAggregationFactory.TOTAL_SUM_FUNC);
  aggregations[3]=new AggregationDefinition(levelNamesForFilter,sortType,funcitons);
  IAggregationResultSet[] resultSet=cubeQueryExcutorHelper.execute(aggregations,new StopSign());
  CubeQueryExecutorHelper.saveAggregationResultSet(pathName,"String_Node_Str",resultSet);
  resultSet=CubeQueryExecutorHelper.loadAggregationResultSet(pathName,"String_Node_Str");
  assertEquals(resultSet[0].length(),2);
  assertEquals(resultSet[0].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[0].getLevelIndex("String_Node_Str"),0);
  assertEquals(resultSet[0].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  resultSet[0].seek(0);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[0].getAggregationValue(0),new Double(6));
  resultSet[0].seek(1);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[0].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[1].length(),4);
  assertEquals(resultSet[1].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[1].getLevelIndex("String_Node_Str"),-1);
  assertEquals(resultSet[1].getLevelIndex("String_Node_Str"),0);
  assertEquals(resultSet[1].getLevelIndex("String_Node_Str"),1);
  assertEquals(resultSet[1].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  assertEquals(resultSet[1].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[1].seek(0);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(1));
  resultSet[1].seek(1);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(5));
  resultSet[1].seek(2);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(9));
  resultSet[1].seek(3);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[1].getLevelKeyValue(1)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(13));
  assertEquals(resultSet[2].length(),2);
  assertEquals(resultSet[2].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[2].getLevelIndex("String_Node_Str"),0);
  assertEquals(resultSet[2].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  resultSet[2].seek(0);
  assertEquals(resultSet[2].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[2].getAggregationValue(0),new Double(6));
  resultSet[2].seek(1);
  assertEquals(resultSet[2].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[2].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[3].length(),2);
  assertEquals(resultSet[3].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[3].getLevelIndex("String_Node_Str"),0);
  assertEquals(resultSet[3].getLevelKeyDataType("String_Node_Str","String_Node_Str"),DataType.STRING_TYPE);
  resultSet[3].seek(0);
  assertEquals(resultSet[3].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[3].getAggregationValue(0),new Double(6));
  resultSet[3].seek(1);
  assertEquals(resultSet[3].getLevelKeyValue(0)[0],"String_Node_Str");
  assertEquals(resultSet[3].getAggregationValue(0),new Double(22));
}