Program: 75691
Project: 75691
Buggy source:
private void testFactTableSaveAndLoad2(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";
  FactTableAccessor factTableConstructor=new FactTableAccessor(documentManager);
  FactTable factTable=factTableConstructor.saveFactTable(NamingUtil.getFactTableName("String_Node_Str"),factTable2,dimensions,measureColumnName,new StopSign());
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getDimensionInfo()[0].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].dimensionLength,FactTable2.L1Col.length);
  assertEquals(factTable.getDimensionInfo()[1].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].dimensionLength,3);
  assertEquals(factTable.getDimensionInfo()[2].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].dimensionLength,12);
  assertEquals(factTable.getMeasureInfo()[0].measureName,"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[0].dataType,DataType.INTEGER_TYPE);
  assertEquals(factTable.getMeasureInfo()[1].measureName,"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[1].dataType,DataType.DOUBLE_TYPE);
  String[] dimensionNames=new String[3];
  dimensionNames[0]="String_Node_Str";
  dimensionNames[1]="String_Node_Str";
  dimensionNames[2]="String_Node_Str";
  IDiskArray[] dimensionPosition=new IDiskArray[3];
  dimensionPosition[0]=new BufferedPrimitiveDiskArray();
  dimensionPosition[0].add(new Integer(10));
  dimensionPosition[0].add(new Integer(11));
  dimensionPosition[1]=new BufferedPrimitiveDiskArray();
  dimensionPosition[1].add(new Integer(1));
  dimensionPosition[1].add(new Integer(2));
  dimensionPosition[2]=new BufferedPrimitiveDiskArray();
  dimensionPosition[2].add(new Integer(3));
  dimensionPosition[2].add(new Integer(4));
  dimensionPosition[2].add(new Integer(5));
  dimensionPosition[2].add(new Integer(10));
  dimensionPosition[2].add(new Integer(11));
  FactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(10,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(10,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(10),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(10),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(11,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(11,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(11),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(11),facttableRowIterator.getMeasure(1));
  assertFalse(facttableRowIterator.next());
}

Fixed version (ground truth):
private void testFactTableSaveAndLoad2(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";
  FactTableAccessor factTableConstructor=new FactTableAccessor(documentManager);
  FactTable factTable=factTableConstructor.saveFactTable(NamingUtil.getFactTableName("String_Node_Str"),CubeUtility.getKeyColNames(dimensions),factTable2,dimensions,measureColumnName,new StopSign());
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getDimensionInfo()[0].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].dimensionLength,FactTable2.L1Col.length);
  assertEquals(factTable.getDimensionInfo()[1].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].dimensionLength,3);
  assertEquals(factTable.getDimensionInfo()[2].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].dimensionLength,12);
  assertEquals(factTable.getMeasureInfo()[0].measureName,"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[0].dataType,DataType.INTEGER_TYPE);
  assertEquals(factTable.getMeasureInfo()[1].measureName,"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[1].dataType,DataType.DOUBLE_TYPE);
  String[] dimensionNames=new String[3];
  dimensionNames[0]="String_Node_Str";
  dimensionNames[1]="String_Node_Str";
  dimensionNames[2]="String_Node_Str";
  IDiskArray[] dimensionPosition=new IDiskArray[3];
  dimensionPosition[0]=new BufferedPrimitiveDiskArray();
  dimensionPosition[0].add(new Integer(10));
  dimensionPosition[0].add(new Integer(11));
  dimensionPosition[1]=new BufferedPrimitiveDiskArray();
  dimensionPosition[1].add(new Integer(1));
  dimensionPosition[1].add(new Integer(2));
  dimensionPosition[2]=new BufferedPrimitiveDiskArray();
  dimensionPosition[2].add(new Integer(3));
  dimensionPosition[2].add(new Integer(4));
  dimensionPosition[2].add(new Integer(5));
  dimensionPosition[2].add(new Integer(10));
  dimensionPosition[2].add(new Integer(11));
  FactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(10,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(10,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(10),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(10),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(11,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(11,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(11),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(11),facttableRowIterator.getMeasure(1));
  assertFalse(facttableRowIterator.next());
}