Program: 75433
Project: 75433
Buggy source:
private void testFactTableSaveAndLoad2(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[3];
  ILevelDefn[] levelDefs=new ILevelDefn[1];
  String[] levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension1Col));
  levelDefs[0]=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");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension2Col));
  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");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension3Col));
  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");
  IDatasetIterator factTableIterator=new LevelsAndFactTableDataset();
  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),factTableIterator,dimensions,measureColumnName,new StopSign());
  assertEquals(factTable.getSegmentCount(),1);
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getSegmentCount(),1);
  assertEquals(factTable.getDimensionInfo()[0].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].dimensionLength,3);
  assertEquals(factTable.getDimensionInfo()[1].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].dimensionLength,7);
  assertEquals(factTable.getDimensionInfo()[2].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].dimensionLength,14);
  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(1));
  dimensionPosition[0].add(new Integer(2));
  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));
  dimensionPosition[2].add(new Integer(4));
  dimensionPosition[2].add(new Integer(5));
  dimensionPosition[2].add(new Integer(6));
  FactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(5,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(211),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(211),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(6,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(212),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(212),facttableRowIterator.getMeasure(1));
  assertFalse(facttableRowIterator.next());
}

Fixed version (ground truth):
private void testFactTableSaveAndLoad2(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[3];
  ILevelDefn[] levelDefs=new ILevelDefn[1];
  String[] levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension1Col));
  levelDefs[0]=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");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension2Col));
  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");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension3Col));
  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");
  IDatasetIterator factTableIterator=new LevelsAndFactTableDataset();
  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),factTableIterator,dimensions,measureColumnName,new StopSign());
  assertEquals(factTable.getSegmentCount(),1);
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getSegmentCount(),1);
  assertEquals(factTable.getDimensionInfo()[0].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].dimensionLength,3);
  assertEquals(factTable.getDimensionInfo()[1].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].dimensionLength,7);
  assertEquals(factTable.getDimensionInfo()[2].dimensionName,"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].dimensionLength,14);
  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(1));
  dimensionPosition[0].add(new Integer(2));
  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));
  dimensionPosition[2].add(new Integer(4));
  dimensionPosition[2].add(new Integer(5));
  dimensionPosition[2].add(new Integer(6));
  FactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(5,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(211),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(211),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(6,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(212),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(212),facttableRowIterator.getMeasure(1));
  assertFalse(facttableRowIterator.next());
}