Program: 75695
Project: 75695
Buggy source:
private void testFactTableSaveAndLoad1(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"),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[1];
  dimensionNames[0]="String_Node_Str";
  IDiskArray[] dimensionPosition=new IDiskArray[1];
  dimensionPosition[0]=new BufferedPrimitiveDiskArray();
  dimensionPosition[0].add(new Integer(1));
  dimensionPosition[0].add(new Integer(2));
  IFactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  facttableRowIterator=new FactTableRowIteratorWithFilter(dimensions,facttableRowIterator);
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(3,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(121),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(121),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(4,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(122),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(122),facttableRowIterator.getMeasure(1));
  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 testFactTableSaveAndLoad1(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[1];
  dimensionNames[0]="String_Node_Str";
  IDiskArray[] dimensionPosition=new IDiskArray[1];
  dimensionPosition[0]=new BufferedPrimitiveDiskArray();
  dimensionPosition[0].add(new Integer(1));
  dimensionPosition[0].add(new Integer(2));
  IFactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  facttableRowIterator=new FactTableRowIteratorWithFilter(dimensions,facttableRowIterator);
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(3,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(121),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(121),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(4,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(122),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(122),facttableRowIterator.getMeasure(1));
  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());
}