Program: 67021
Project: 67021
Buggy source:
private void testFactTableSaveAndLoad(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,FactTable1.L1Col);
  iterator.setLevelMember(1,FactTable1.L2Col);
  iterator.setLevelMember(2,FactTable1.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,new StopSign());
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[0].length(),FactTable1.L1Col.length);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(FactTable1.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,new StopSign());
  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);
  int[] lL1Col={1,2,3};
  iterator.setLevelMember(0,lL1Col);
  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,new StopSign());
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[2].length(),3);
  FactTable1 factTable1=new FactTable1();
  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),CubeUtility.getKeyColNames(dimensions),factTable1,dimensions,measureColumnName,new StopSign(),false);
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getDimensionInfo()[0].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].getDimensionLength(),FactTable1.L1Col.length);
  assertEquals(factTable.getDimensionInfo()[1].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].getDimensionLength(),3);
  assertEquals(factTable.getDimensionInfo()[2].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].getDimensionLength(),3);
  assertEquals(factTable.getMeasureInfo()[0].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[0].getDataType(),DataType.INTEGER_TYPE);
  assertEquals(factTable.getMeasureInfo()[1].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[1].getDataType(),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(1));
  dimensionPosition[2].add(new Integer(2));
  dimensionPosition[2].add(new Integer(3));
  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(2,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(2,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 testFactTableSaveAndLoad(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,FactTable1.L1Col);
  iterator.setLevelMember(1,FactTable1.L2Col);
  iterator.setLevelMember(2,FactTable1.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,new StopSign());
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[0].length(),FactTable1.L1Col.length);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(FactTable1.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,new StopSign());
  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);
  int[] lL1Col={1,2,3};
  iterator.setLevelMember(0,lL1Col);
  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,new StopSign());
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[2].length(),3);
  FactTable1 factTable1=new FactTable1();
  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),CubeUtility.getKeyColNames(dimensions),factTable1,dimensions,measureColumnName,new StopSign());
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getDimensionInfo()[0].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].getDimensionLength(),FactTable1.L1Col.length);
  assertEquals(factTable.getDimensionInfo()[1].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].getDimensionLength(),3);
  assertEquals(factTable.getDimensionInfo()[2].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].getDimensionLength(),3);
  assertEquals(factTable.getMeasureInfo()[0].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[0].getDataType(),DataType.INTEGER_TYPE);
  assertEquals(factTable.getMeasureInfo()[1].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[1].getDataType(),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(1));
  dimensionPosition[2].add(new Integer(2));
  dimensionPosition[2].add(new Integer(3));
  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(2,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(2,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(11),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(11),facttableRowIterator.getMeasure(1));
  assertFalse(facttableRowIterator.next());
}