Program: 76253
Project: 76253
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);
  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);
  hierarchy=dimensions[1].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[1].length(),3);
  levelNames=new String[2];
  levelNames[0]="String_Node_Str";
  levelNames[1]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  int[] lL1Col={1,1,2,2,3,3};
  int[] lL2Col={1,2,1,2,2,3};
  iterator.setLevelMember(0,lL1Col);
  iterator.setLevelMember(1,lL2Col);
  levelDefs=new ILevelDefn[2];
  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);
  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(),6);
  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"),factTable1,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,FactTable1.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,6);
  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));
  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(5,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(5,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);
  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);
  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);
  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"),factTable1,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,FactTable1.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,3);
  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(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());
}